gpt4 book ai didi

gradle - 在干净的生成版本中找不到符号

转载 作者:行者123 更新时间:2023-12-02 07:02:34 26 4
gpt4 key购买 nike

我正在创建一个外部模块,或者我应该为现有的移动项目应用程序创建一个库,因为我无法调整其内部结构(代码、配置等),

这个库的唯一目的只是执行 API 调用(即在服务器和客户端项目(应用程序)之间接受和返回数据),它在开发中工作得很好,但是当我尝试构建这个库时方式

gradlew clean build generateRelease --stacktrace

我在堆栈跟踪上遇到此类错误

 error: cannot find symbol
@SerializedName("FirstName")
^

我发现改造确实有

  minifyEnabled true

然后我了解了 proguard 规则,使用来自不同来源和不同测试的这些行,

 -keep class com.google.code.gson.** { *; }
-keep class com.google.code.gson.annotations** { *; }
-keep class retrofit2.** { *; }

-keepclassmembernames interface * {
@retrofit.http.* <methods>;
}

-keep class retrofit2.** { *; }
-keepclassmembernames interface * {
@retrofit2.http.* <methods>;
}

-keep class sun.misc.Unsafe { *; }
-keep class com.google.code.gson.stream.** { *; }

-keepattributes Signature
-keepattributes *Annotation*

这些规则的不同组合,但我在构建时仍然遇到问题,这些规则是在库/模块的proguard-rules.pro上编码的

我不知道问题是否来自混淆器规则,因为我已经测试了很多 -keep 属性。任何帮助将不胜感激。

这是库的 build.gradle

 apply plugin: 'com.android.library'



android {
compileSdkVersion 25
buildToolsVersion "25.0.2"

defaultConfig {
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"

testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

lintOptions {
abortOnError false
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
testCompile 'junit:junit:4.12'

compile 'com.android.support:appcompat-v7:25.3.0'

compile 'com.squareup.retrofit2:retrofit:2.2.0'
compile 'com.squareup.retrofit2:converter-gson:2.2.0'
compile 'com.google.code.gson:gson:2.8.0'
}

apply from: 'https://raw.githubusercontent.com/blundell/release-android-
library/master/android-release-aar.gradle'

最佳答案

对我来说,在将以下内容添加到您的 proguard 文件后,您的项目已成功构建并启用了缩小功能:

-dontwarn okio.**
-dontwarn retrofit2.Platform$Java8

关于gradle - 在干净的生成版本中找不到符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42942668/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com