【问题标题】:Error:Gradle: Execution failed for task ':androidLib:compileDebugJavaWithJavac'. > Compilation failed; see the compiler error output for details错误:Gradle:任务':androidLib:compileDebugJavaWithJavac'的执行失败。 > 编译失败;有关详细信息,请参阅编译器错误输出
【发布时间】:2016-08-06 04:23:31
【问题描述】:

我已经收到这个错误两天了,到目前为止我没有尝试过任何工作。

我已经清理了它,重建了它,使缓存失效,更新了 Android Studio 及其构建工具,但绝对没有任何效果。我的 JAVA_HOME 很好,SDK 很好。我检查了所有内容,但它似乎不起作用。

androidLib 是我正在使用的一个库,它是这样的

androidLib 几乎包含了我所有的依赖项 模板 common 是我创建的一个模块,它具有 androidLib 作为依赖项(它包含在 settings.gradle 及其各自的构建中) 模板是我的项目,它具有模板通用作为依赖项,因此它也有 androidLib

但它一直给我这个错误,根本没有任何 androidLib 依赖项被访问,包括 app compact 和类似的东西。

这是androidLib gradle

apply plugin: 'com.android.library'



dependencies {
      compile('io.socket:socket.io-client:0.7.0') {
        // excluding org.json which is provided by Android
        exclude group: 'org.json', module: 'json'
    }
       compile 'com.android.support:support-v4:23.3.0'
       compile 'com.android.support:appcompat-v7:23.3.0'
       compile 'com.android.support:design:23.3.0'
       compile 'com.android.support:cardview-v7:23.3.0'
       compile 'com.android.support:recyclerview-v7:23.3.0'
       compile 'com.android.support:multidex:1.0.1'
       compile 'com.google.android.gms:play-services:8.4.0'
       compile 'com.google.code.gson:gson:2.4'
       compile 'com.fasterxml.jackson.core:jackson-core:2.5.0'
       compile 'com.fasterxml.jackson.core:jackson-annotations:2.5.0'
       compile 'com.fasterxml.jackson.core:jackson-databind:2.5.0'
       compile 'com.j256.ormlite:ormlite-android:4.48'
       compile 'com.j256.ormlite:ormlite-core:4.48'
       compile 'org.springframework.android:spring-android-core:1.0.1.RELEASE'
       compile 'org.springframework.android:spring-android-rest-    template:1.0.1.RELEASE'
       compile 'com.vividsolutions:jts:1.13'
       compile 'com.noveogroup.android:android-logger:1.3.5'
       compile 'com.google.android.gms:play-services-ads:8.4.0'
       compile 'com.google.android.gms:play-services-identity:8.4.0'
       compile 'com.google.android.gms:play-services-gcm:8.4.0'
   }

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
    minSdkVersion 16
    targetSdkVersion 23
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
packagingOptions {
    exclude 'META-INF/DEPENDENCIES.txt'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/notice.txt'
    exclude 'META-INF/license.txt'
    exclude 'META-INF/dependencies.txt'
    exclude 'META-INF/LGPL2.1'
    exclude 'META-INF/ASL2.0'
}

}

这是模板通用 gradle

apply plugin: 'com.android.library'

android {
    compileSdkVersion 23
    buildToolsVersion '23.0.2'

defaultConfig {
    minSdkVersion 16
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"

}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
packagingOptions {
    exclude 'META-INF/DEPENDENCIES.txt'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/notice.txt'
    exclude 'META-INF/license.txt'
    exclude 'META-INF/dependencies.txt'
    exclude 'META-INF/LGPL2.1'
    exclude 'META-INF/ASL2.0'
}

}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'net.xpece.material:navigation-drawer:0.7.6@aar'
    compile 'com.isseiaoki:simplecropview:1.0.13'
    compile 'com.stripe:stripe-android:+'
    compile 'io.card:android-sdk:5.1.2'
    compile 'com.facebook.android:facebook-android-sdk:4.6.0'
    compile 'com.helpshift:android-aar:4.2.0-support'
    compile 'com.github.jd-alexander:library:1.0.8'
    compile project(':androidLib')
   }

这就是项目 gradle

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"
    defaultConfig {
        applicationId "br.com.altranais.template"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    dexOptions {
        incremental true
        javaMaxHeapSize "4g"
    }
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LGPL2.1'
        exclude 'META-INF/ASL2.0'
    }
    productFlavors {
    }
}

repositories {
    mavenCentral()
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile project(':templatecommon')
}

Gradle 控制台

Executing tasks: [clean, :app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:prepareDebugUnitTestDependencies, :app:mockableAndroidJar, :app:compileDebugSources, :app:compileDebugAndroidTestSources, :app:compileDebugUnitTestSources, :androidLib:generateDebugSources, :androidLib:generateDebugAndroidTestSources, :androidLib:prepareDebugUnitTestDependencies, :androidLib:mockableAndroidJar, :androidLib:compileDebugSources, :androidLib:compileDebugAndroidTestSources, :androidLib:compileDebugUnitTestSources, :templatecommon:generateDebugSources, :templatecommon:prepareDebugUnitTestDependencies, :templatecommon:mockableAndroidJar, :templatecommon:generateDebugAndroidTestSources, :templatecommon:compileDebugSources, :templatecommon:compileDebugUnitTestSources, :templatecommon:compileDebugAndroidTestSources]

Configuration on demand is an incubating feature.
Incremental java compilation is an incubating feature.
:clean
:androidLib:clean
:app:clean UP-TO-DATE
:templatecommon:clean UP-TO-DATE
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:androidLib:preBuild UP-TO-DATE
:androidLib:preReleaseBuild UP-TO-DATE
:androidLib:compileReleaseNdk UP-TO-DATE
:androidLib:compileLint
:androidLib:copyReleaseLint UP-TO-DATE
:androidLib:checkReleaseManifest
:androidLib:preDebugAndroidTestBuild UP-TO-DATE
:androidLib:preDebugBuild UP-TO-DATE
:androidLib:preDebugUnitTestBuild UP-TO-DATE
:androidLib:preReleaseUnitTestBuild UP-TO-DATE
:androidLib:prepareComAndroidSupportAnimatedVectorDrawable2330Library
:androidLib:prepareComAndroidSupportAppcompatV72330Library
:androidLib:prepareComAndroidSupportCardviewV72330Library
:androidLib:prepareComAndroidSupportDesign2330Library
:androidLib:prepareComAndroidSupportMediarouterV72300Library
:androidLib:prepareComAndroidSupportMultidex101Library
:androidLib:prepareComAndroidSupportRecyclerviewV72330Library
:androidLib:prepareComAndroidSupportSupportV42330Library
:androidLib:prepareComAndroidSupportSupportVectorDrawable2330Library
:androidLib:prepareComGoogleAndroidGmsPlayServices840Library
:androidLib:prepareComGoogleAndroidGmsPlayServicesAds840Library
:androidLib:prepareComGoogleAndroidGmsPlayServicesAnalytics840Library
:androidLib:prepareComGoogleAndroidGmsPlayServicesAppindexing840Library
:androidLib:prepareComGoogleAndroidGmsPlayServicesAppinvite840Library
:androidLib:prepareComGoogleAndroidGmsPlayServicesAppstate840Library
:androidLib:prepareComGoogleAndroidGmsPlayServicesAuth840Library
:androidLib:prepareComGoogleAndroidGmsPlayServicesBase840Library
:androidLib:prepareComGoogleAndroidGmsPlayServicesBasement840Library
:androidLib:prepareComGoogleAndroidGmsPlayServicesCast840Library
:androidLib:prepareComGoogleAndroidGmsPlayServicesDrive840Library
:androidLib:prepareComGoogleAndroidGmsPlayServicesFitness840Library
:androidLib:prepareComGoogleAndroidGmsPlayServicesGames840Library
:androidLib:prepareComGoogleAndroidGmsPlayServicesGcm840Library
:androidLib:prepareComGoogleAndroidGmsPlayServicesIdentity840Library
:androidLib:prepareComGoogleAndroidGmsPlayServicesLocation840Library
:androidLib:prepareComGoogleAndroidGmsPlayServicesMaps840Library
:androidLib:prepareComGoogleAndroidGmsPlayServicesMeasurement840Library
:androidLib:prepareComGoogleAndroidGmsPlayServicesNearby840Library
:androidLib:prepareComGoogleAndroidGmsPlayServicesPanorama840Library
:androidLib:prepareComGoogleAndroidGmsPlayServicesPlus840Library
:androidLib:prepareComGoogleAndroidGmsPlayServicesSafetynet840Library
:androidLib:prepareComGoogleAndroidGmsPlayServicesVision840Library
:androidLib:prepareComGoogleAndroidGmsPlayServicesWallet840Library
:androidLib:prepareComGoogleAndroidGmsPlayServicesWearable840Library
:androidLib:prepareReleaseDependencies
:androidLib:compileReleaseAidl
:androidLib:compileReleaseRenderscript
:androidLib:generateReleaseBuildConfig
:androidLib:generateReleaseAssets UP-TO-DATE
:androidLib:mergeReleaseAssets
:androidLib:generateReleaseResValues UP-TO-DATE
:androidLib:generateReleaseResources
:androidLib:mergeReleaseResources
:androidLib:processReleaseManifest
:androidLib:processReleaseResources
:androidLib:generateReleaseSources
:androidLib:compileReleaseJavaWithJavac
/Users/Leonardo/Documents/Android/androidLib/src/main/java/br/com/altranais/lib/activity/AISActivity.java:23: error: cannot find symbol
public class AISActivity extends ActionBarActivity {
                                 ^
  symbol: class ActionBarActivity
/Users/Leonardo/Documents/Android/androidLib/src/main/java/br/com/altranais/lib/activity/AISActivity.java:29: error: cannot find symbol
    protected DrawerLayout drawerLayout;
              ^
  symbol:   class DrawerLayout
  location: class AISActivity
/Users/Leonardo/Documents/Android/androidLib/src/main/java/br/com/altranais/lib/activity/AISActivity.java:36: error: cannot find symbol
    protected ActionBarDrawerToggle actionBarDrawerToggle;
              ^
  symbol:   class ActionBarDrawerToggle
  location: class AISActivity
/Users/Leonardo/Documents/Android/androidLib/src/main/java/br/com/altranais/lib/activity/AISActivity.java:42: error: cannot find symbol
        super.onCreate(savedInstanceState);
        ^
  symbol:   variable super
  location: class AISActivity
/Users/Leonardo/Documents/Android/androidLib/src/main/java/br/com/altranais/lib/activity/AISActivity.java:43: error: cannot find symbol
        setContentView(R.layout.activity_ais);
                               ^
  symbol:   variable activity_ais
  location: class layout
/Users/Leonardo/Documents/Android/androidLib/src/main/java/br/com/altranais/lib/activity/AISActivity.java:40: error: method does not override or implement a method from a supertype
    @Override
    ^
/Users/Leonardo/Documents/Android/androidLib/src/main/java/br/com/altranais/lib/activity/AISActivity.java:51: error: cannot find symbol
        frameLayout = (FrameLayout)findViewById(R.id.content_frame);
                                                    ^
  symbol:   variable content_frame
  location: class id
/Users/Leonardo/Documents/Android/androidLib/src/main/java/br/com/altranais/lib/activity/AISActivity.java:52: error: cannot find symbol
        drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
                        ^
  symbol:   class DrawerLayout
  location: class AISActivity
/Users/Leonardo/Documents/Android/androidLib/src/main/java/br/com/altranais/lib/activity/AISActivity.java:52: error: cannot find symbol
        drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
                                                       ^
  symbol:   variable drawer_layout
  location: class id
/Users/Leonardo/Documents/Android/androidLib/src/main/java/br/com/altranais/lib/activity/AISActivity.java:53: error: cannot find symbol
        drawerList = (ListView) findViewById(R.id.left_drawer);
                                                 ^
  symbol:   variable left_drawer
  location: class id
/Users/Leonardo/Documents/Android/androidLib/src/main/java/br/com/altranais/lib/activity/AISActivity.java:54: error: cannot find symbol
        titles = getResources().getStringArray(R.array.titles);
                 ^
  symbol:   method getResources()
  location: class AISActivity
/Users/Leonardo/Documents/Android/androidLib/src/main/java/br/com/altranais/lib/activity/AISActivity.java:55: error: cannot find symbol
        images = getResources().obtainTypedArray(R.array.images);
                 ^
  symbol:   method getResources()
  location: class AISActivity
/Users/Leonardo/Documents/Android/androidLib/src/main/java/br/com/altranais/lib/activity/AISActivity.java:56: error: cannot find symbol
        activities = getResources().getStringArray(R.array.activities);
                     ^
  symbol:   method getResources()
  location: class AISActivity
/Users/Leonardo/Documents/Android/androidLib/src/main/java/br/com/altranais/lib/activity/AISActivity.java:57: error: cannot find symbol
        textCurrentUser = (TextView)drawerLayout.findViewById(R.id.user_name);
                                                                  ^
  symbol:   variable user_name
  location: class id
/Users/Leonardo/Documents/Android/androidLib/src/main/java/br/com/altranais/lib/activity/AISActivity.java:58: error: cannot find symbol
        imageFotoView = (ImageView) findViewById(R.id.fotoView);
                                                     ^
  symbol:   variable fotoView
  location: class id
/Users/Leonardo/Documents/Android/androidLib/src/main/java/br/com/altranais/lib/activity/AISActivity.java:59: error: cannot find symbol
        actionBarDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.loading,R.string.loading){
                                    ^
  symbol:   class ActionBarDrawerToggle
  location: class AISActivity
/Users/Leonardo/Documents/Android/androidLib/src/main/java/br/com/altranais/lib/activity/AISActivity.java:87: error: cannot find symbol
        super.onDestroy();
        ^
  symbol:   variable super
  location: class AISActivity
/Users/Leonardo/Documents/Android/androidLib/src/main/java/br/com/altranais/lib/activity/AISActivity.java:85: error: method does not override or implement a method from a supertype
    @Override
    ^
/Users/Leonardo/Documents/Android/androidLib/src/main/java/br/com/altranais/lib/activity/AISActivity.java:95: error: no suitable method found for makeText(AISActivity,String,int)
                Toast.makeText(AISActivity.this, message, Toast.LENGTH_LONG).show();
                     ^
    method Toast.makeText(Context,int,int) is not applicable
      (actual argument AISActivity cannot be converted to Context by method invocation conversion)
    method Toast.makeText(Context,CharSequence,int) is not applicable
      (actual argument AISActivity cannot be converted to Context by method invocation conversion)
/Users/Leonardo/Documents/Android/androidLib/src/main/java/br/com/altranais/lib/activity/AISActivity.java:92: error: cannot find symbol
        this.runOnUiThread(new Runnable() {
            ^
  symbol: method runOnUiThread(<anonymous Runnable>)
/Users/Leonardo/Documents/Android/androidLib/src/main/java/br/com/altranais/lib/activity/AISActivity.java:102: error: cannot find symbol
        Log.d(getClass().getSimpleName(), obj == null ? "NULL" : obj.toString());
              ^
  symbol:   method getClass()
  location: class AISActivity
/Users/Leonardo/Documents/Android/androidLib/src/main/java/br/com/altranais/lib/activity/AISActivity.java:106: error: cannot find symbol
        Log.e(getClass().getSimpleName(), obj == null ? "NULL" : obj.toString(), tr);
              ^
  symbol:   method getClass()
  location: class AISActivity
/Users/Leonardo/Documents/Android/androidLib/src/main/java/br/com/altranais/lib/activity/AISActivity.java:110: error: cannot find symbol
        View view = findViewById(id);
                    ^
  symbol:   method findViewById(int)
  location: class AISActivity
/Users/Leonardo/Documents/Android/androidLib/src/main/java/br/com/altranais/lib/activity/AISActivity.java:131: error: cannot find symbol
        this.showProgressDialog(getString(R.string.loading));
                                ^
  symbol:   method getString(int)
  location: class AISActivity
/Users/Leonardo/Documents/Android/androidLib/src/main/java/br/com/altranais/lib/activity/AISActivity.java:136: error: no suitable constructor found for ProgressDialog(AISActivity)
            progressDialog = new ProgressDialog(this);
                             ^
    constructor ProgressDialog.ProgressDialog(Context,int) is not applicable
      (actual and formal argument lists differ in length)
    constructor ProgressDialog.ProgressDialog(Context) is not applicable
      (actual argument AISActivity cannot be converted to Context by method invocation conversion)
/Users/Leonardo/Documents/Android/androidLib/src/main/java/br/com/altranais/lib/activity/AISActivity.java:151: error: no suitable constructor found for Builder(AISActivity)
        AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);
                                          ^
    constructor Builder.Builder(Context,int) is not applicable
      (actual and formal argument lists differ in length)
    constructor Builder.Builder(Context) is not applicable
      (actual argument AISActivity cannot be converted to Context by method invocation conversion)
/Users/Leonardo/Documents/Android/androidLib/src/main/java/br/com/altranais/lib/activity/AISActivity.java:165: error: cannot find symbol
        super.onPostCreate(savedInstanceState);
        ^
  symbol:   variable super
  location: class AISActivity
/Users/Leonardo/Documents/Android/androidLib/src/main/java/br/com/altranais/lib/activity/AISActivity.java:163: error: method does not override or implement a method from a supertype
    @Override
    ^
/Users/Leonardo/Documents/Android/androidLib/src/main/java/br/com/altranais/lib/activity/AISActivity.java:171: error: cannot find symbol
        super.onConfigurationChanged(newConfig);
        ^
  symbol:   variable super
  location: class AISActivity
/Users/Leonardo/Documents/Android/androidLib/src/main/java/br/com/altranais/lib/activity/AISActivity.java:169: error: method does not override or implement a method from a supertype
    @Override
    ^
/Users/Leonardo/Documents/Android/androidLib/src/main/java/br/com/altranais/lib/activity/AISNavigationActivity.java:28: error: cannot find symbol
        navigationDrawerAdapter = new AISNavigationDrawerAdapter(getApplicationContext(), titles, images);
                                                                 ^
  symbol:   method getApplicationContext()
  location: class AISNavigationActivity
/Users/Leonardo/Documents/Android/androidLib/src/main/java/br/com/altranais/lib/activity/AISNavigationActivity.java:36: error: cannot find symbol
            drawerLayout.closeDrawer((LinearLayout) findViewById(R.id.left_container));
                                                                     ^
  symbol:   variable left_container
  location: class id
/Users/Leonardo/Documents/Android/androidLib/src/main/java/br/com/altranais/lib/activity/AISNavigationActivity.java:37: error: cannot find symbol
            onActivityInteractionListener.openActivityInteraction(getApplicationContext(),position);
                                                                  ^
  symbol:   method getApplicationContext()
  location: class AISNavigationActivity.DrawerItemClickListener
/Users/Leonardo/Documents/Android/androidLib/src/main/java/br/com/altranais/lib/adapters/AISNavigationDrawerAdapter.java:52: error: package R does not exist
        view = inflater.inflate(R.layout.drawer_list_item, null);
                                 ^
/Users/Leonardo/Documents/Android/androidLib/src/main/java/br/com/altranais/lib/adapters/AISNavigationDrawerAdapter.java:53: error: package R does not exist
        TextView txt=(TextView)view.findViewById(R.id.section_label);
                                                  ^
/Users/Leonardo/Documents/Android/androidLib/src/main/java/br/com/altranais/lib/adapters/AISNavigationDrawerAdapter.java:57: error: package R does not exist
        ImageView imageView = (ImageView)view.findViewById(R.id.icon_list);
                                                            ^
Note: /Users/Leonardo/Documents/Android/androidLib/src/main/java/br/com/altranais/lib/adapters/AISNavigationDrawerAdapter.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /Users/Leonardo/Documents/Android/androidLib/src/main/java/br/com/altranais/lib/socket/SocketClient.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
36 errors

 FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':androidLib:compileReleaseJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 23.847 secs

谢谢

【问题讨论】:

  • 请从 Gradle 输出中添加错误消息。
  • 几乎所有的错误都是因为 lib 没有被访问

标签: android android-studio gradle dependencies android-gradle-plugin


【解决方案1】:

我遇到了类似的问题。手动删除构建目录为我修复了它。

【讨论】:

    【解决方案2】:

    问题出在 gradle 中,我最近更新到 Android Studio 2.0,它搞砸了一切。不得不回到旧的 Android Studio 来修复它并能够在 2.0 上使用它

    【讨论】:

    • 出了什么问题?
    猜你喜欢
    • 2018-10-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-31
    • 2017-10-06
    • 2018-04-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多