Android编译库错误
Android compile library error
我正在尝试使用库 NCHART3D
我的build.gradle
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.android.test3dchart"
minSdkVersion 16
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 files('libs/NChart3D.jar')
}
和logcat打印:
Couldn't load nchart3d from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.android.test3dchart-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.android.test3dchart-2, /vendor/lib, /system/lib]]]: findLibrary returned null
01-15 13:29:50.177 2793-2793/com.example.android.chart D/dalvikvm﹕ Late-enabling CheckJNI
01-15 13:29:50.267 2793-2793/com.example.android.chart W/dalvikvm﹕ Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lcom/nulana/NChart/NChartView;
01-15 13:29:50.267 2793-2793/com.example.android.chart W/dalvikvm﹕ Class init failed in Constructor.constructNative (Lcom/nulana/NChart/NChartView;)
01-15 13:29:50.267 2793-2793/com.example.android.chart D/AndroidRuntime﹕ Shutting down VM
01-15 13:29:50.267 2793-2793/com.example.android.chart W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x415778b0)
01-15 13:29:50.277 2793-2793/com.example.android.chart E/AndroidRuntime﹕ FATAL EXCEPTION: main
更新
在 xml 预览中
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.nulana.NChart.NChartView
android:id="@+id/surface"
android:layout_height="fill_parent"
android:layout_width="fill_parent"/>
</LinearLayout>
呈现问题无法找到以下 类:
- com.nulana.NChart.NChartView(修复构建路径,创建 Class)
提示:尝试构建项目。
我猜这是因为冗余,在下面的代码第一行中已经包含了你的 jar。
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/NChart3D.jar')
尝试删除编译文件('libs/NChart3D.jar'),然后清理项目并重建
确保您有以下项目结构,并注意您的 jar 应该进入 libs 文件夹和 jniLibs 中的其他 lib 组件。这是 android studio 1.0
我正在尝试使用库 NCHART3D
我的build.gradle
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.android.test3dchart"
minSdkVersion 16
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 files('libs/NChart3D.jar')
}
和logcat打印:
Couldn't load nchart3d from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.android.test3dchart-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.android.test3dchart-2, /vendor/lib, /system/lib]]]: findLibrary returned null
01-15 13:29:50.177 2793-2793/com.example.android.chart D/dalvikvm﹕ Late-enabling CheckJNI
01-15 13:29:50.267 2793-2793/com.example.android.chart W/dalvikvm﹕ Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lcom/nulana/NChart/NChartView;
01-15 13:29:50.267 2793-2793/com.example.android.chart W/dalvikvm﹕ Class init failed in Constructor.constructNative (Lcom/nulana/NChart/NChartView;)
01-15 13:29:50.267 2793-2793/com.example.android.chart D/AndroidRuntime﹕ Shutting down VM
01-15 13:29:50.267 2793-2793/com.example.android.chart W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x415778b0)
01-15 13:29:50.277 2793-2793/com.example.android.chart E/AndroidRuntime﹕ FATAL EXCEPTION: main
更新 在 xml 预览中
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.nulana.NChart.NChartView
android:id="@+id/surface"
android:layout_height="fill_parent"
android:layout_width="fill_parent"/>
</LinearLayout>
呈现问题无法找到以下 类: - com.nulana.NChart.NChartView(修复构建路径,创建 Class) 提示:尝试构建项目。
我猜这是因为冗余,在下面的代码第一行中已经包含了你的 jar。
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/NChart3D.jar')
尝试删除编译文件('libs/NChart3D.jar'),然后清理项目并重建
确保您有以下项目结构,并注意您的 jar 应该进入 libs 文件夹和 jniLibs 中的其他 lib 组件。这是 android studio 1.0