gpt4 book ai didi

android - 当我运行 apk 但不是从 Android Studio 运行时出现错误

转载 作者:行者123 更新时间:2023-11-29 01:52:07 28 4
gpt4 key购买 nike

当我编译我的 apk 时,我在“运行”apk 时遇到错误,这是:

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.. 这是我的“build.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')
}
}

最佳答案

您的错误状态:

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

您的 gradle 构建配置将其显示为依赖项,但您可能想检查您的模块指向支持库的路径。

Android Studio 很可能无法检测到您的支持库不可用,因此您可以编译,但看到应用程序失败。

关于android - 当我运行 apk 但不是从 Android Studio 运行时出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17304974/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com