2015-01-15 158 views
1

我嘗試使用庫NCHART3D的Android編譯庫錯誤

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 

UPDATE 在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(修復構建路徑,創建類) 提示:嘗試構建項目。

回答

1

我想這是因爲冗餘,在下面的代碼第一行已經包括你的jar。

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

嘗試刪除編譯文件(「庫/ NChart3D.jar」),再用乾淨的項目和重建

請確保您有以下項目結構,並注意你的罐子應該進入libs文件夾和jniLibs中的其他lib組件。這對於機器人工作室1.0

project tree

+0

IM嘗試:依賴{ 編譯文件樹(DIR: '庫',包括:[ '的* .jar']) 編譯「com.android.support:appcompat- v7:21.0.3' }沒有工作:/ – Luis 2015-01-15 19:14:21

+0

即時更新問題... – Luis 2015-01-15 19:15:48

+0

@Luis我的猜測是你沒有正確的項目結構。我下載了NChart3D庫並嘗試了一個演示項目,它沒有任何錯誤或交戰。我更新了我的答案,結帳圖片,並確保您有正確的項目結構 – Vilen 2015-01-16 07:54:04