我的Android应用程序在模拟器上工作正常,甚至在我使用USB线连接它时在设备上。但是,当我生成apk文件并与其他人共享时,该应用程序无法正常工作。启动闪屏后,它会崩溃。
这是我的app / build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '25.0.0'
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId 'com.test'
minSdkVersion 15
targetSdkVersion 22
versionCode 2
versionName "1.1"
multiDexEnabled true
def serverPropertiesFile = rootProject.file("server.properties")
// Initialize a new Properties() object called keystoreProperties.
def serverProperties = new Properties()
// Load your keystore.properties file into the serverProperties object.
serverProperties.load(new FileInputStream(serverPropertiesFile))
buildConfigField("String", "HOST", serverProperties['SERVER_URL'])
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
debuggable true
}
}
productFlavors {
}
lintOptions {
abortOnError false
} } dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.daimajia.swipelayout:library:1.2.0@aar'
compile 'com.daimajia.androidanimations:library:1.1.2@aar'
compile 'com.google.android.gms:play-services-maps:10.0.1'
compile 'com.google.android.gms:play-services-gcm:10.0.1'
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'com.google.code.gson:gson:2.8.2'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}
的Manifest.xml:
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.CALL_PHONE"/>
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<!--
The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
Google Maps Android API v2, but you must specify either coarse or fine
location permissions for the 'MyLocation' functionality.
-->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
任何帮助?
答案 0 :(得分:2)
我认为您缺少API 23或更高版本的运行时权限
尝试为相机,位置和电话提供运行时权限。以下是添加运行时权限的示例。
https://developer.android.com/training/permissions/requesting.html
How to check Grants Permissions at Run-Time?
https://www.androidhive.info/2016/11/android-working-marshmallow-m-runtime-permissions/
检查是否缺少运行时权限问题转到电话Settings
- &gt; Apps
- &gt; Installed App
- &gt; Your App
- &gt; Permissions
- &gt; Allow Permissions
那里
答案 1 :(得分:2)
我认为你需要在pro-guard文件中添加一些类。例如,Gson不会很好地处理混淆。要查看这是否确实导致了问题,请删除minifyEnabled true
。
答案 2 :(得分:0)
转到构建,然后单击generate / build apk。点击运行生成的apks适用于具有相同API级别的设备。
答案 3 :(得分:0)
我认为你在APK版本中遇到了问题。检查您的移动APK版本和目标APK版本。当您使用25.0.0
构建时,您的应用程序将不会运行低于APK版本25