App在marshmallow 6.0.1中运行时崩溃了

时间:2016-12-12 12:34:25

标签: android

我已经开发了Android应用程序,它适用于我的三星note 3 android 5.0,但当我试图在两个设备(三​​星S7和索尼Z5)与marshmallow 6.0.1安装它崩溃。下面是构建gradle:

完成Gradle

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion '24.0.2'
defaultConfig {
applicationId "com.example.user.cellularnetworkinfor_v8"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),     'proguard-rules.pro'
}
}
productFlavors {
}
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile files('libs/opencsv-3.7.jar')
  }

**********************************清单************ ***************

  <?xml version="1.0" encoding="utf-8"?>
  <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.example.user.cellularnetworkinfor_v8">

<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_UPDATES"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>


<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

3 个答案:

答案 0 :(得分:0)

这可能是因为某些危险的权限,你必须从android 6.0指定运行时权限,危险权限的一些例子是Access_fine_location,read和writememory等,

要确认,请在此处发布您的logcat

答案 1 :(得分:0)

这可能是因为Android M How to ask permission runtime的功能,或者是您可以手动指定的检查权限问题 android M Device中的settings -> Apps -> Configure Apps

另请参阅此帖Marshallow changing permissions at run time crashes app

答案 2 :(得分:0)

您需要 RunTimePermission
请参阅此如何获取权限运行时https://stackoverflow.com/a/34722591/4741746