无法从库项目中解析符号类名

时间:2017-03-14 09:57:37

标签: android build android-gradle

我已将应用 libraryApp 添加为其他应用 XYZ 的库项目。当我构建 libraryApp 作为应用程序时,它工作正常,但如果我将其添加为库,那么在应用程序模块中,它会为每个类提供“无法解析符号”图书馆模块。

  

build.gradle( libraryApp 库模块)

apply plugin: 'com.android.library'
apply plugin: 'io.fabric'

apply plugin: 'com.jakewharton.butterknife'

buildscript {
    repositories {
        mavenCentral()
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
        classpath 'com.jakewharton:butterknife-gradle-plugin:8.5.1'
    }
}

repositories {
    maven { url 'https://maven.fabric.io/public' }
}

android {
    compileSdkVersion appCompileSdkVersion
    buildToolsVersion appBuildToolsVersion
    compileOptions.encoding = 'ISO-8859-1'

    defaultConfig {
//        applicationId "com.abc"
        minSdkVersion appMinSdkVersion
        targetSdkVersion appTargetSdkVersion
        versionCode 92
        versionName "4.0.0.7"
        multiDexEnabled true
        resValue "string", "softversion", "4.0.0.7"
        resValue 'string', "app_name", "Vibe"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
          debuggable false
        }
        debug {
            debuggable true
        }
    }

    lintOptions {
        checkReleaseBuilds false
        // Or, if you prefer, you can continue to check for errors in release builds,
        // but continue the build even when errors are found:
        abortOnError false
    }
}

dependencies {

    compile project(':captureActivity')
    compile files('libs/mframework.jar')
    compile files('libs/voiceRecog.jar')
    compile('com.crashlytics.sdk.android:crashlytics:2.6.5@aar') {
        transitive = true;
    }

    compile 'com.jakewharton:butterknife:8.2.0'

    compile 'com.jakewharton:butterknife-compiler:8.2.0'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'com.android.support:design:25.1.0'
    compile 'com.android.support:cardview-v7:25.1.0'
    compile 'com.android.support:customtabs:25.1.0'
    compile 'org.greenrobot:eventbus:3.0.0'
    compile 'com.google.firebase:firebase-messaging:10.0.1'
    compile ('com.squareup.retrofit2:converter-simplexml:2.0.2'){
        exclude module: 'stax-api'
        exclude module: 'stax'
        exclude module: 'xpp3'
    }
    compile 'com.makeramen:roundedimageview:2.3.0'
    compile 'com.wdullaer:materialdatetimepicker:3.1.1'

    compile 'com.android.support:support-v4:25.1.0'
    compile 'com.android.support:support-annotations:25.1.0'
    compile 'com.android.support:recyclerview-v7:25.1.0'
    // retrofit and its supporting libraries
    compile 'com.squareup.retrofit2:retrofit:2.0.2'
    compile ('com.squareup.retrofit2:converter-gson:2.0.2') {
        exclude group: 'stax', module: 'stax-api'
        exclude group: 'stax', module: 'stax'
        exclude group: 'xpp3', module: 'xpp3'
    }
    compile 'com.squareup.okhttp3:logging-interceptor:3.2.0'
    compile 'com.squareup.okhttp3:okhttp-urlconnection:3.2.0'

    // logger to log string in logcat
    compile 'com.orhanobut:logger:1.15'

    compile 'com.android.support:multidex:1.0.1'

    compile 'com.android.support:support-vector-drawable:25.1.0'
    compile 'com.android.support:animated-vector-drawable:25.1.0'


    testCompile 'junit:junit:4.12'

    compile 'com.android.support.constraint:constraint-layout:1.0.0-beta1'
}
apply plugin: 'com.google.gms.google-services'
  

build.gradle( XYZ app模块)

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }
}
apply plugin: 'com.android.application'

android {
    compileSdkVersion appCompileSdkVersion
    buildToolsVersion appBuildToolsVersion
    compileOptions.encoding = 'ISO-8859-1'

    defaultConfig {
        applicationId "com.vinay.vibe"
        minSdkVersion appMinSdkVersion
        targetSdkVersion appTargetSdkVersion
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
            debuggable false
        }
        debug {
            debuggable true
        }
    }
    sourceSets { main { assets.srcDirs = ['src/main/assets', 'src/main/assets/'] } }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')

    compile 'com.mcxiaoke.volley:library:1.0.19'
    compile 'com.facebook.android:facebook-android-sdk:4.6.0'

    compile project(':libraryApp')
}

apply plugin: 'com.google.gms.google-services'

1 个答案:

答案 0 :(得分:0)

您必须在setting.gradle文件中添加模块

include ':XYZ' , ':libraryApp '

或者你可以在android studio的项目结构中的模块中添加它,按alt+ctrl+shift并在模块选项卡中按+按钮并添加你的模块