简体   繁体   English

Android Studio-生成文件夹下的文件,不应编辑

[英]Android Studio - Files under the build folder are generated and should not be edited

I have gone through similar questions posted on StackOverflow regarding this issue, but none of them solved my problem. 我曾就此问题经历过StackOverflow上发布的类似问题,但没有一个问题解决了我的问题。

So, as in all questions, I am getting errors while trying to compile the application. 因此,就像所有问题一样,在尝试编译应用程序时出现错误。

在此处输入图片说明

I know, i shouldn't edit this debug->AndroidManifest.xml file as its auto-generated. 我知道,我不应该将此debug-> AndroidManifest.xml文件编辑为自动生成的文件。 But, the app->AndroidManifest.xml file doesn't show any errors??? 但是,app-> AndroidManifest.xml文件没有显示任何错误??? What should i edit when there are no errors? 没有错误时该怎么办?

here is my AndroidManifest.xml file: 这是我的AndroidManifest.xml文件:

<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.test.awstestapp">


    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    <uses-permission android:name="com.google.android.c2dm.permission.REGISTER" />
    <uses-permission android:name="com.test.awstestapp.permission.C2D_MESSAGE" />

    <permission
        android:name="com.test.awstestapp.permission.C2D_MESSAGE"
        android:protectionLevel="signature" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher_image"
        android:label="@string/app_name"
        android:theme="@style/AppTheme">
        <activity
            android:name="com.test.awstestapp.AndroidMobilePushApp"
            android:label="@string/app_name"
            android:launchMode="singleTop">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <service
            android:name="com.test.awstestapp.MessageReceivingService"
            android:label="com.test.awstestapp.MessageReceivingService">
            <intent-filter>
                <action android:name="com.test.awstestapp.AndroidMobilePushApp" />
                <action android:name="com.test.awstestapp.ExternalReceiver" />

                <category android:name="com.test.awstestapp" />
            </intent-filter>
        </service>

        <receiver
            android:name="com.test.awstestapp.ExternalReceiver"
            android:permission="com.google.android.c2dm.permission.SEND">
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
                <action android:name="com.google.android.c2dm.intent.REGISTER" />

                <category android:name="com.test.awstestapp" />
            </intent-filter>
        </receiver>
    </application>
</manifest>

The AndroidManifest.xml file in build->....->debug, is as below: build-> ....-> debug中的AndroidManifest.xml文件如下:

<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.test.awstestapp"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="10"
        android:targetSdkVersion="22" />

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    <uses-permission android:name="com.google.android.c2dm.permission.REGISTER" />
    <uses-permission android:name="com.test.awstestapp.permission.C2D_MESSAGE" />

    <permission
        android:name="com.test.awstestapp.permission.C2D_MESSAGE"
        android:protectionLevel="signature" />

    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" />

    <android:uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

    <uses-permission android:name="android.permission.USE_CREDENTIALS" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher_image"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.test.awstestapp.AndroidMobilePushApp"
            android:label="@string/app_name"
            android:launchMode="singleTop" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <service
            android:name="com.test.awstestapp.MessageReceivingService"
            android:label="com.test.awstestapp.MessageReceivingService" >
            <intent-filter>
                <action android:name="com.test.awstestapp.AndroidMobilePushApp" />
                <action android:name="com.test.awstestapp.ExternalReceiver" />

                <category android:name="com.test.awstestapp" />
            </intent-filter>
        </service>

        <receiver
            android:name="com.test.awstestapp.ExternalReceiver"
            android:permission="com.google.android.c2dm.permission.SEND" >
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
                <action android:name="com.google.android.c2dm.intent.REGISTER" />

                <category android:name="com.test.awstestapp" />
            </intent-filter>
        </receiver>
        <!-- Include the AdActivity and InAppPurchaseActivity configChanges and themes. -->
        <activity
            android:name="com.google.android.gms.ads.AdActivity"
            android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
            android:theme="@android:style/Theme.Translucent" />
        <activity
            android:name="com.google.android.gms.ads.purchase.InAppPurchaseActivity"
            android:theme="@style/Theme.IAPTheme" />

        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />
        <meta-data
            android:name="com.google.android.gms.wallet.api.enabled"
            android:value="true" />

        <receiver
            android:name="com.google.android.gms.wallet.EnableWalletOptimizationReceiver"
            android:exported="false" >
            <intent-filter>
                <action android:name="com.google.android.gms.wallet.ENABLE_WALLET_OPTIMIZATION" />
            </intent-filter>
        </receiver>
    </application>

</manifest>

Why is the auto generated manifest different from the original? 为什么自动生成的清单与原始清单不同?

Solutions tried till now: 迄今为止尝试过的解决方案:

  1. Clean Project 清洁项目
  2. File->Invalidate Caches/Restart 文件->使缓存无效/重新启动
  3. Renamed ic_launcher to ic_launcher_image (just to test if the file name is causing the issue). 将ic_launcher重命名为ic_launcher_image(仅用于测试文件名是否引起了问题)。

Here are the errors that are being shown in Logcat: 以下是Logcat中显示的错误:

在此处输入图片说明

How can i solve this? 我该如何解决?

In your first screenshot I see red wrigles below the names of two files: AndroidMobilePushApp.java and MessageReceivingService.java. 在您的第一个屏幕截图中,我在两个文件的名称下方看到红色的皱纹:AndroidMobilePushApp.java和MessageReceivingService.java。 You should solve these errors to solve your build problems. 您应该解决这些错误以解决构建问题。 This could magically solve your resource problems, because there is some dependence between correctly building the app, copying the resources to the build map etc. 这可以神奇地解决您的资源问题,因为正确构建应用程序,将资源复制到构建地图等之间存在一定的依赖关系。

I am guessing that Android Studio didn't recognise the images when they are copied using explorer outside the IDE. 我猜想在IDE外部使用资源管理器复制图像时,Android Studio无法识别图像。 So, i deleted the folders, created new folders for all 4 drawables and copied the files one by one. 因此,我删除了文件夹,为所有4个可绘制对象创建了新文件夹,并一一复制了文件。 Now the errors and gone and the application got compiled. 现在错误消失了,应用程序被编译了。

在android studio中,您必须修改gradle文件的版本

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM