在Gradle构建之后,Android Studio找不到库类 [英] Android Studio can't find library classes after Gradle build

查看:805
本文介绍了在Gradle构建之后,Android Studio找不到库类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 .jar 库添加到我的项目到 / libs 文件夹中。这是我的 grade.build

I'm trying to add a .jar library to my project into the /libs folder. Here is my grade.build:

    buildscript {
        repositories {
            mavenCentral()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:0.4'
        }
    }
    apply plugin: 'android'

    dependencies {
        compile files('libs/android-support-v4.jar', 'libs/java-api-wrapper-1.2.0-all.jar')
    }

    android {
        compileSdkVersion 17
        buildToolsVersion "17.0.0"

        defaultConfig {
            minSdkVersion 15
            targetSdkVersion 16
        }
    }

添加后我建立我的项目,没有错误。但是当我尝试在我的代码 private ApiWrapper wrapper 中使用类时,我收到一个错误:

After I add that, I build my project and there are no errors. But when I try to use the class in my code private ApiWrapper wrapper, I get an error:

Gradle: error: cannot find symbol class ApiWrapper

我不能找到错误在哪里。我的 grade.build 不行,或者我应该用其他方式构建它?

I can't quite find where the error is. Is my grade.build not ok, or am I supposed to build it some other way?

推荐答案

使用命令行,在项目的根目录中运行:

./ gradlew clean&& ./gradlew build

Using the command line, in the root of your project, run :
./gradlew clean && ./gradlew build

然后在studio中重新编译你的项目,你应该会看到你的新lib。

Then recompile your project in studio and you should see your new lib.

这篇关于在Gradle构建之后,Android Studio找不到库类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆