我是android开发的新手。 我正在一个项目中进行不同的活动,其中两个使用jSon解析。
我的问题是,即使在测试时,我的ap在某些设备上也可以正常工作,而在某些设备上却无法正常工作。在这个问题上,我看上去无数烦恼,但是没有什么能解决我的问题。我还遇到其他一些问题,但是我通过查看可用的答案解决了这些问题,但是这个“未安装”的问题仍然存在。我已完成以下操作:
我担心的是活动内部可能存在什么问题,最后应安装该应用程序并启动第一个活动(即通过线程实现的启动屏幕),但是: 该应用程序在两种方式下都可以在我的设备(Redmi 4)上正常运行,即通过USB和带有签名的apk。 该应用程序在我的一些朋友的设备中运行良好,这些设备来自Honor,Lenovo,MI等制造商。 但是相同的apk无法在其他设备 Redmi 4 的另一个版本上安装,这对我来说是最奇怪的问题。 在某些设备中,无论是通过USB还是使用签名的APK进行安装,都会在我打开设备时崩溃。
但是,由于该应用在某些设备上运行良好,因此我认为问题不在内部活动中。
我已经阅读并尝试过的一些答案是:
Cannot install signed apk to device manually, got error “App not installed”
Getting “App Not Installed” on some devices from signed apk
答案中提供了每个内部链接。
注意:有些活动完全是出于测试目的。
这是我的清单文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.diginfoexpert.MBAutodeals">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name=".Globals"
android:allowBackup="true"
android:icon="@mipmap/audi"
android:roundIcon="@mipmap/audi_round"
android:supportsRtl="true"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
android:testOnly="false"
android:largeHeap="true">
<activity android:name=".Web_json_product_Activity"></activity>
<activity android:name=".Web_jsonActivity">
</activity>
<activity android:name=".jSonParseActivity"></activity>
<activity android:name=".SignUpActivity"
android:noHistory="true"/>
<activity android:name=".LoginActivity"
android:noHistory="true"/>
<activity android:name=".ProductActivity" />
<activity android:name=".IntroActivity" />
<activity
android:name=".SplashScreenActivity"
android:noHistory="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity" />
</application>
</manifest>
这是我的build.gradle文件(应用程序)
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.0"
defaultConfig {
applicationId "com.diginfoexpert.MBAutodeals"
minSdkVersion 18
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.preference:preference:1.1.0-alpha05'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.android.volley:volley:1.1.1'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'gr.pantrif:easy-android-splash-screen:0.0.1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'com.google.firebase:firebase-core:17.0.0'
implementation 'com.google.firebase:firebase-appindexing:19.0.0'
implementation 'com.google.firebase:firebase-auth:18.0.0'
implementation 'com.google.firebase:firebase-database:18.0.0'
implementation 'com.google.firebase:firebase-storage:18.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
apply plugin: 'com.google.gms.google-services'
这是安装该应用程序时的日志,但当我尝试打开它时崩溃:
07-10 12:31:25.402 2278-4229/? E/Surface: getSlotFromBufferLocked: unknown buffer: 0x7f5d1f6b60
07-10 12:31:25.408 4049-4177/? E/Surface: getSlotFromBufferLocked: unknown buffer: 0x7f47e481c0
07-10 12:31:25.508 22804-22804/? E/Minikin: addFont failed to create font /system/fonts/NanumGothic.ttf
07-10 12:31:25.508 22804-22804/? E/Minikin: addFont failed to create font /system/fonts/DroidSansFallback.ttf
07-10 12:31:25.508 22804-22804/? E/Minikin: addFont failed to create font /system/fonts/MTLmr3m.ttf
07-10 12:31:25.603 22804-22804/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.diginfoexpert.MBAutodeals, PID: 22804
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.diginfoexpert.MBAutodeals/com.diginfoexpert.MBAutodeals.SplashScreenActivity}: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class android.widget.RelativeLayout
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2560)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2626)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1475)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5740)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:766)
Caused by: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class android.widget.RelativeLayout
at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:532)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161)
at com.diginfoexpert.MBAutodeals.SplashScreenActivity.onCreate(SplashScreenActivity.java:14)
at android.app.Activity.performCreate(Activity.java:6543)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2513)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2626)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1475)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5740)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:766)
Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class android.widget.RelativeLayout
at android.view.LayoutInflater.createView(LayoutInflater.java:645)
at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:694)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:762)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:532)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161)
at com.diginfoexpert.MBAutodeals.SplashScreenActivity.onCreate(SplashScreenActivity.java:14)
at android.app.Activity.performCreate(Activity.java:6543)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2513)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2626)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1475)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5740)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:766)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Native Method)
at android.view.LayoutInflater.createView(LayoutInflater.java:619)
at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:694)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:762)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:532)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161)
at com.diginfoexpert.MBAutodeals.SplashScreenActivity.onCreate(SplashScreenActivity.java:14)
at android.app.Activity.performCreate(Activity.java:6543)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2513)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2626)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1475)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5740)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:766)
Caused by: android.content.res.Resources$NotFoundException: Resource "com.diginfoexpert.MBAutodeals:drawable/car_background" (7f070069) is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f070069 a=-1 r=0x7f070069}
at android.content.res.Resources.loadDrawableForCookie(Resources.java:2842)
at android.content.res.Resources.loadDrawable(Resources.java:2764)
at android.content.res.TypedArray.getDrawable(TypedArray.java:870)
at android.view.View.<init>(View.java:4001)
at android.view.ViewGroup.<init>(ViewGroup.java:599)
at android.widget.RelativeLayout.<init>(RelativeLayout.java:268)
at android.widget.RelativeLayout.<init>(RelativeLayout.java:264)
at android.widget.RelativeLayout.<init>(RelativeLayout.java:260)
at java.lang.reflect.Constructor.newInstance(Native Method)
at android.view.LayoutInflater.createView(LayoutInflater.java:619)
at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:694)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:762)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:532)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161)
at com.diginfoexpert.MBAutodeals.SplashScreenActivity.onCreate(SplashScreenActivity.java:14)
at android.app.Activity.performCreate(Activity.java:6543)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2513)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2626)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1475)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5740)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:766)
07-10 12:31:26.339 1012-1724/? E/Sensors: handleToDriver handle(0)
07-10 12:31:26.339 1012-1724/? E/Sensors: handleToDriver handle(0)
07-10 12:31:26.340 1012-1724/? E/Sensors: new setDelay handle(0),ns(20000000)m, error(0), index(2)
07-10 12:31:26.341 1012-1724/? E/Accel: ACC batch: handle:0, en:0,samplingPeriodNs:20000000 maxBatchReportLatencyNs:0
07-10 12:31:26.341 1012-1724/? E/Sensors: sensor 0 go to common batch
07-10 12:31:26.341 1012-1724/? E/Sensors: handleToDriver handle(0)
07-10 12:31:26.362 1012-1263/? E/Sensors: readEvents: no events readed, continue to try next fd
07-10 12:31:26.382 1012-1263/? E/Sensors: readEvents: no events readed, continue to try next fd
07-10 12:31:26.402 1012-1263/? E/Sensors: readEvents: no events readed, continue to try next fd
07-10 12:31:26.422 1012-1263/? E/Sensors: readEvents: no events readed, continue to try next fd
07-10 12:31:26.442 1012-1263/? E/Sensors: readEvents: no events readed, continue to try next fd
07-10 12:31:26.462 1012-1263/? E/Sensors: readEvents: no events readed, continue to try next fd
07-10 12:31:26.482 1012-1263/? E/Sensors: readEvents: no events readed, continue to try next fd
07-10 12:31:26.502 1012-1263/? E/Sensors: readEvents: no events readed, continue to try next fd
07-10 12:31:26.522 1012-1263/? E/Sensors: readEvents: no events readed, continue to try next fd
07-10 12:31:26.542 1012-1263/? E/Sensors: readEvents: no events readed, continue to try next fd
07-10 12:31:26.562 1012-1263/? E/Sensors: readEvents: no events readed, continue to try next fd
07-10 12:31:26.582 1012-1263/? E/Sensors: readEvents: no events readed, continue to try next fd
07-10 12:31:26.602 1012-1263/? E/Sensors: readEvents: no events readed, continue to try next fd
07-10 12:31:26.622 1012-1263/? E/Sensors: readEvents: no events readed, continue to try next fd
07-10 12:31:26.642 1012-1263/? E/Sensors: readEvents: no events readed, continue to try next fd
07-10 12:31:26.663 1012-1263/? E/Sensors: readEvents: no events readed, continue to try next fd
07-10 12:31:26.682 1012-1263/? E/Sensors: readEvents: no events readed, continue to try next fd
07-10 12:31:26.847 285-569/? E/MAL-Daemon: ( rds_ru_3gpp_status_ind, 1421) [RDS-E][RU][EVENT_RU_DM_3GPP_STATUS_IND] Invalid u43gpp_status:0x6
这是build.gradle文件(项目级别):
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
classpath 'com.google.gms:google-services:4.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
classpath 'com.google.gms:google-services:4.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
答案 0 :(得分:1)
Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class android.widget.RelativeLayout
此行告诉您xml格式错误。尝试检查android.widget.RelativeLayout
答案 1 :(得分:0)
如果已在设备上安装了 debug apk,请从菜单选项转到应用程序信息并为所有用户卸载 ,然后尝试再次安装您的发行版APK。
答案 2 :(得分:0)
检查步骤 -检查应用程序是否已经安装在未安装应用程序的手机上 -在共享apk文件时,请确保已关闭Play商店中该手机Redmi4的安全设置。
比您不会遇到的问题
答案 3 :(得分:0)
我在Redmi设备上也遇到了类似的问题,对我来说,解决方法是使用Android Studio中的“使用设备文件资源管理器”选项在“下载内容”中复制签名的apk,然后安装该apk。
使用ADB安装不适用于Redmi设备