sha*_*anu 18 android android-studio android-gradle-plugin
我有两个项目A和B,其中B被添加为项目A的模块.我在A的Gradle构建文件中添加了依赖项.现在我可以在A中导入B的类而没有任何错误(在编辑器中)但无法构建.偏好是一类项目B.
Error:(22, 23) error: cannot find symbol class Preferences
Run Code Online (Sandbox Code Playgroud)
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.0.0"
defaultConfig {
applicationId "com.example.A"
minSdkVersion 9
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile project(':B')
}
Run Code Online (Sandbox Code Playgroud)
import org.apache.tools.ant.taskdefs.condition.Os
apply plugin: "android-library"
android {
compileSdkVersion 18
buildToolsVersion "21.0.0"
defaultConfig {
minSdkVersion 9
targetSdkVersion 11
}
buildTypes {
release {
minifyEnabled true
proguardFiles 'proguard.cfg'
}
}
sourceSets.main {
jniLibs.srcDir 'src/main/jniLibs'
jni.srcDirs = [] //disable automatic ndk-build call
}
task ndkBuild(type: Exec) {
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
commandLine 'ndk-build.cmd', '-C', file('src/main/jni').absolutePath
} else {
commandLine '/opt/adt-bundle-linux/android-ndk-r8e/ndk-build', '-C', file('src/main/jni').absolutePath
}
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn ndkBuild
}
}
}
dependencies {
compile 'com.android.support:support-v4:18.0.0'
}
Run Code Online (Sandbox Code Playgroud)
如果删除导入,我可以成功构建项目(A).
Win*_*der 43
如果库(无论是本地模块还是外部依赖项)具有minifyEnabled true,但库的ProGuard配置缺失或不正确(该类有资格通过ProGuard删除),则可能发生这种情况.这导致课程没有被编译.
小智 10
对我来说这是一个类似的问题,但在proguard conf.proguard在第一个库中处于活动状态,在第二个库中处于非活动状态.
所有build.gradle上的Copie相同的proguard conf已经解决了"找不到符号类"的错误.
| 归档时间: |
|
| 查看次数: |
38922 次 |
| 最近记录: |