2013-10-05 113 views
2

我想在我的項目中添加畢加索圖書館,但我的項目出現錯誤。 我使用jdk 7和android studio 0.2.11Android Studio添加庫錯誤?

這是我的錯誤。我tryed8小時但同樣一次錯誤並重新

請幫助

遺憾的英語不好。

10-05 21:02:45.891 32262-32262/? E/AndroidRuntime﹕ FATAL EXCEPTION: main 
    java.lang.NoClassDefFoundError: com.squareup.picasso.Picasso 
      at com.medyasef.androidfirsttime.MainActivity.onCreate(MainActivity.java:20) 
      at android.app.Activity.performCreate(Activity.java:5133) 
      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175) 
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261) 
      at android.app.ActivityThread.access$600(ActivityThread.java:141) 
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256) 
      at android.os.Handler.dispatchMessage(Handler.java:99) 
      at android.os.Looper.loop(Looper.java:137) 
      at android.app.ActivityThread.main(ActivityThread.java:5103) 
      at java.lang.reflect.Method.invokeNative(Native Method) 
      at java.lang.reflect.Method.invoke(Method.java:525) 
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737) 
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 
      at dalvik.system.NativeStart.main(Native Method) 

這是MainActivity.java

package com.medyasef.androidfirsttime; 

import android.os.Bundle; 
import android.app.Activity; 
import android.view.Menu; 
import android.widget.ImageView; 

import com.squareup.picasso.Picasso; 

public class MainActivity extends Activity { 

    private ImageView imageView; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 

     imageView = (ImageView) findViewById(R.id.imageView); 
     Picasso.with(this).load("http://i.imgur.com/DvpvklR.png").into(imageView); 

    } 


    @Override 
    public boolean onCreateOptionsMenu(Menu menu) { 
     // Inflate the menu; this adds items to the action bar if it is present. 
     getMenuInflater().inflate(R.menu.main, menu); 
     return true; 
    } 

的build.gradle

buildscript { 
    repositories { 
     mavenCentral() 
    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:0.5.+' 
    } 
} 
apply plugin: 'android' 

repositories { 
    mavenCentral() 
} 

android { 
    compileSdkVersion 18 
    buildToolsVersion "18.1.0" 

    defaultConfig { 
     minSdkVersion 9 
     targetSdkVersion 16 
    } 
} 

dependencies { 
    compile 'com.android.support:appcompat-v7:18.0.0' 
    compile files('libs/picasso-2.1.1.jar') 
} 
+0

包含文件夾「庫」的確切名爲lib? – staaar

+0

@staaar我嘗試過,但又錯誤。 –

回答

14

替換行

compile files('libs/picasso-2.1.1.jar') 

compile 'com.squareup.picasso:picasso:2.1.1' 

這樣您就不必將Picasso .jar添加到libs文件夾中。相反,它會直接從Maven Central提取圖書館。

+0

非常非常好。 İts固定.D非常大thanx你我的英雄.D –

3

「建設 - >重建」 Android Studio中的選項幫助對我來說

+1

是的這個選項幫助我,因爲 –