【问题标题】:Android compile library errorAndroid编译库错误
【发布时间】:2015-01-15 18:36:04
【问题描述】:

我正在尝试使用库 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(修复构建路径,创建类) 提示:尝试构建项目。

【问题讨论】:

    标签: android android-studio build.gradle


    【解决方案1】:

    我猜这是因为冗余,在下面的代码第一行中已经包含了你的 jar。

    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile files('libs/NChart3D.jar')
    

    尝试删除编译文件('libs/NChart3D.jar'),然后清理项目并重建

    确保您具有以下项目结构,并注意您的 jar 应放入 libs 文件夹和 jniLibs 中的其他 lib 组件。这适用于 android studio 1.0

    【讨论】:

    • im try : dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:21.0.3' } no工作:/
    • @Luis 我猜你的项目结构不正确。我下载了 NChart3D 库并尝试了其中一个演示项目,它可以正常工作,没有任何错误或冲突。我更新了我的答案,结帐图片,并确保你有正确的项目结构
    猜你喜欢
    • 2015-08-08
    • 2018-12-23
    • 2017-12-02
    • 2013-12-25
    • 2013-05-19
    • 1970-01-01
    • 2013-10-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多