我从this repo下载了代码,并为其创建了一个项目,并将所有源代码复制到新项目中。
新项目成功构建。
该项目包含两个模块示例和库:
模块库包含一些类和一些资源ID
模块样本取决于库。在设备上运行应用程序时,它会崩溃,但例外情况为:
W/dalvikvm(13442): VFY: unable to resolve static field 5319 (expandable_toggle_button) in Lcom/tjerkw/slideexpandable/library/R$id;
D/dalvikvm(13442): VFY: replacing opcode 0x60 at 0x0000
I/dalvikvm(13442): DexOpt: unable to optimize static field ref 0x14c6 at 0x02 in Lcom/tjerkw/slideexpandable/library/SlideExpandableListAdapter;.<init>
D/AndroidRuntime(13442): Shutting down VM
W/dalvikvm(13442): threadid=1: thread exiting with uncaught exception (group=0x41c75da0)
E/AndroidRuntime(13442): FATAL EXCEPTION: main
E/AndroidRuntime(13442): Process: com.lxj.testslideexpandablelistview, PID: 13442
E/AndroidRuntime(13442): java.lang.NoClassDefFoundError: com.tjerkw.slideexpandable.library.R$id
E/AndroidRuntime(13442): at com.tjerkw.slideexpandable.library.SlideExpandableListAdapter.<init>(SlideExpandableListAdapter.java:25)
E/AndroidRuntime(13442): at com.tjerkw.slideexpandable.library.SlideExpandableListView.setAdapter(SlideExpandableListView.java:43)
E/AndroidRuntime(13442): at com.tjerkw.slideexpandable.library.ActionSlideExpandableListView.setAdapter(ActionSlideExpandableListView.java:56)
E/AndroidRuntime(13442): at com.tjerkw.slideexpandable.sample.ExampleActivity.onCreate(ExampleActivity.java:35)
我提取+反编译apk文件,并找到资源ID,但具有不同的值:
public static final int expandable_toggle_button = 2131230725;
如何解决?我在互联网上搜索,所有文章都指的是Eclipse,但我使用的是Android Studio。有人可以帮忙吗?感谢。
root build.gradle是这样的:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.13.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
库build.gradle:
apply plugin: 'com.android.library'
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
defaultConfig {
applicationId "com.lxj.slideexpandablelistview"
// minSdkVersion 11
// targetSdkVersion 21
versionCode 1
versionName "1.0"
}
// buildTypes {
// release {
// runProguard false
// proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
// }
// }
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.0'
}
示例build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
defaultConfig {
applicationId "com.lxj.testslideexpandablelistview"
// minSdkVersion 11
// targetSdkVersion 21
versionCode 1
versionName "1.0"
}
// buildTypes {
// release {
// runProguard false
// proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
// }
// }
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.0'
compile project(':library')
}