2013-06-25 57 views
2

運行APK當我編譯我的apk「跑」的APK,這個時候我得到一個錯誤:我得到一個錯誤,當我而不是從Android工作室

java.lang.RuntimeException: Unable to start activity   
ComponentInfo{com.robsie.quiz/com.robsie.quiz.SplashActivity}:  
android.view.InflateException: Binary XML file line #7: Error inflating class 
android.support.v4.view.ViewPager 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2309) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2359) 
at android.app.ActivityThread.access$600(ActivityThread.java:153) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1247) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:137) 
at android.app.ActivityThread.main(ActivityThread.java:5202) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:511) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:799) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:566) 
at dalvik.system.NativeStart.main(Native Method) 
Caused by: android.view.InflateException: Binary XML file line #7: Error inflating  
class android.support.v4.view.ViewPager 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:698) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:746) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:489) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:352) 
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270) 
at android.app.Activity.setContentView(Activity.java:1885) 
at com.robsie.quiz.SplashActivity.onCreate(Unknown Source) 
at android.app.Activity.performCreate(Activity.java:5108) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2263) 
... 11 more 
Caused by: java.lang.ClassNotFoundException: Didn't find class  
"android.support.v4.view.ViewPager" on path: /data/app/com.robsie.quiz-1.apk 
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65) 
at java.lang.ClassLoader.loadClass(ClassLoader.java:501) 
at java.lang.ClassLoader.loadClass(ClassLoader.java:461) 
at android.view.LayoutInflater.createView(LayoutInflater.java:552) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687) 
... 21 more 

但是,當我從Android的打開Studio中,如果第一個「重建工程」,然後「運行」我不明白沒有..如果只有我「跑」我得到這個錯誤..

java: can not find symbol 
symbol: Variable layout 
location: class com.robsie.quiz.R 

進出口使用CirclePageIndicator ..這是我的「建設.gradle'

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

dependencies { 
    compile files('libs/GoogleAdMobAdsSdk-6.4.1.jar') 
    compile files('libs/android-support-v4.jar') 
    compile fileTree(dir: 'libs', include: '*.jar') 
    compile project(':C::Users:shekel:Desktop:WorkSpace:library') 

} 

android { 
    compileSdkVersion 11 
    buildToolsVersion "17.0.0" 

    sourceSets { 
     main { 
      manifest.srcFile 'AndroidManifest.xml' 
      java.srcDirs = ['src'] 
      resources.srcDirs = ['src'] 
      aidl.srcDirs = ['src'] 
      renderscript.srcDirs = ['src'] 
      res.srcDirs = ['res'] 
      assets.srcDirs = ['assets'] 
     } 

     instrumentTest.setRoot('tests') 
    } 
} 

回答

1

你的錯誤狀態:

Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v4.view.ViewPager" 

你gradle這個構建的配置顯示了它作爲一個依賴,但你可能要到你的模塊點檢查哪裏路徑明智的支持庫。

Android Studio很可能無法檢測到您的支持庫不可用,因此您可以編譯但看到應用程序失敗。

0

嗯,我還沒有使用過Android Studio,但對我來說,它看起來像是一個已知的ADT錯誤,您必須明確標記要導出的外部庫,this answer顯示了它在Eclipse中的工作方式。

0

我有同樣的錯誤消息。

爲了與滑動式標籤(ViewPager)動作條建設活動

我所做的就是:更新至最新的Android版本(目前0.4.4)

它打開新項目嚮導中,選擇導航類型:

動作欄選項卡(與ViewPager),如下

enter image description here

相關問題