问题描述
我开始一个简单的应用程序,通过按下按钮发送短信。由于我需要网络,因此我正在手机上测试此功能。该应用程序第一次生成罚款,但由于我忘了添加权限 android.permission.SEND_SMS
,按钮按下后没有做任何事情。
I'm starting a simple app to send an SMS at the press of a button. I'm testing this on my mobile phone since i need the network. The app build fine the first time but the button press didn't do anything since i forgot to add the permission android.permission.SEND_SMS
. Once i added that then faced with following error.
Error:java.io.FileNotFoundException: C:\Users\user\AndroidStudioProjects\myApp\app\build\intermediates\res\resources-debug.ap_ (Access is denied)
C:\Users\user\AndroidStudioProjects\myApp\app\build\intermediates\res\resources-debug.ap_ (Access is denied)
清单
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.test.android.myapp">
<uses-permission android:name="android.permission.SEND_SMS" />
<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"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
如果我删除使用权限
标签该应用程序构建没有问题。但是,当我添加它失败。任何帮助将不胜感激!
If I delete the uses-permission
tag the app builds without a problem. But when I add it it fails. Any assistance would be greatly appreciated!
Gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.test.android.myapp"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:design:23.2.1'
}
推荐答案
我想它了!对于试图解决这个问题的其他人,您需要 android.permission.SEND_SMS
和 android.permission.RECEIVE_SMS
in您的清单:
I figured it out! To anyone else trying to figure this out, you need both android.permission.SEND_SMS
and android.permission.RECEIVE_SMS
in your manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.test.android.myapp">
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<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"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
这篇关于Android:添加SEND_SMS权限会导致gradle构建失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!