【发布时间】:2023-03-20 00:54:01
【问题描述】:
我将我的 Android Studio 更新到 1.0.1。我按照本教程http://tools.android.com/tech-docs/new-build-system/migrating-to-1-0-0 并从runProguard 更改为minifyEnabled true。我也在我的图书馆项目中改变了它。当我尝试编译时,它给了我Error:Execution failed for task ':> java.io.FileNotFoundException: ProjectName\library\proguard-rules.txt (The system cannot find the file specified)。我为此进行了研究,并找到了解决方案。我在该文件夹中添加了空白 proguard-rules.txt 文件。尝试编译后,它给了我更多错误。现在的主要错误是它cannot find symbol class PageIndicator,这是我图书馆的课程。我什至不知道我能做些什么。
我项目的 build.gradle:
apply plugin: 'android'
android {
compileSdkVersion 21
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.miesto.meniu"
minSdkVersion 9
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(':library')
compile files('libs/volley.jar')
compile 'com.google.android.gms:play-services:6.1.71'
compile 'com.android.support:appcompat-v7:21.0.0'
compile 'com.android.support:support-v4:21.0.0'
compile 'com.squareup.picasso:picasso:2.3.2'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.daimajia.slider:library:1.1.0@aar'
compile('com.google.api-client:google-api-client-xml:1.17.0-rc') {
exclude group: 'com.google.android.google-play-services'
}
compile 'com.google.http-client:google-http-client-gson:1.17.0-rc'
compile('com.google.api-client:google-api-client-android:1.17.0-rc') {
exclude group: 'com.google.android.google-play-services'
}
compile 'com.google.apis:google-api-services-drive:v2-rev105-1.17.0-rc'
compile files('libs/YouTubeAndroidPlayerApi.jar')
}
我的库的 build.gradle:
apply plugin: 'com.android.library'
android {
compileSdkVersion 21
buildToolsVersion "20.0.0"
defaultConfig {
minSdkVersion 9
targetSdkVersion 19
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:21.0.0'
}
我做错了什么?
【问题讨论】:
-
将适当的规则添加到
proguard-android.txt以告诉 ProGuard-keep您的库的公共 API。 -
proguard-android.txt 位于此处 C:\sdk\tools\proguard\proguard-android.txt ?我该怎么做?
-
糟糕,抱歉,我抓错了文件名。我的意思是您添加到项目中的
proguard-rules.txt。我为我的错误道歉。 -
我不确定我是否必须这样写:
-keep class com.viewpagerindicator.**? -
这可能行得通,其中一行或多行表明您不能重命名或删除哪些类。
标签: android android-studio android-library build.gradle