Gradle sync失败:无法读取packageName

时间:2017-10-06 15:53:51

标签: android android-manifest manifest

我尝试了很多解决方案,但都没有效果。如果有人可以在这里帮忙那就太好了。我已经导入了这个有API 21的项目,但是我有API 26.如果你想知道代码中的任何进一步细节,请告诉我。我完全不知道我哪里出错了所以如果有人能告诉我这种情况有什么可能的解决方案会很好吗?

清单文件如下:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.myapps.documentscanner"
    android:installLocation="auto">


    <uses-sdk android:minSdkVersion="21" />

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

    <uses-feature
        android:name="android.hardware.camera"
        android:required="false" />
    <uses-feature
        android:name="android.hardware.camera.autofocus"
        android:required="false" />

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

    <application
        android:name=".DocumentScannerApplication"
        android:allowBackup="true"
        android:fullBackupContent="false"
        android:hardwareAccelerated="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:largeHeap="true"
        android:supportsRtl="true"
        android:theme="@style/Theme.AppCompat">

        <receiver android:name="WidgetProvider">
            <intent-filter>
                <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
            </intent-filter>
            <meta-data
                android:name="android.appwidget.provider"
                android:resource="@xml/simple_widget_info" />
        </receiver>

        <meta-data
            android:name="com.google.android.gms.vision.DEPENDENCIES"
            android:value="ocr" />

        <!--
          Optionally, register AnalyticsReceiver and AnalyticsService to support background
          dispatching on non-Google Play devices
        -->
        <receiver
            android:name="com.google.android.gms.analytics.AnalyticsReceiver"
            android:enabled="true">
            <intent-filter>
                <action android:name="com.google.android.gms.analytics.ANALYTICS_DISPATCH" />
            </intent-filter>
        </receiver>

        <service
            android:name="com.google.android.gms.analytics.AnalyticsService"
            android:enabled="true"
            android:exported="false" />

        <!--
             Optionally, register CampaignTrackingReceiver and CampaignTrackingService to enable
             installation campaign reporting
        -->
        <receiver
            android:name="com.google.android.gms.analytics.CampaignTrackingReceiver"
            android:exported="true">
            <intent-filter>
                <action android:name="com.android.vending.INSTALL_REFERRER" />
            </intent-filter>
        </receiver>

        <service android:name="com.google.android.gms.analytics.CampaignTrackingService" />

        <activity
            android:name=".DocumentScannerActivity"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:label="@string/title_activity_document_scanner"
            android:screenOrientation="portrait"
            android:theme="@style/FullscreenTheme.NoActionBar">

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.media.action.IMAGE_CAPTURE" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
        <activity
            android:name=".GalleryGridActivity"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:label="@string/title_activity_gallery"
            android:screenOrientation="portrait"
            android:theme="@style/FullscreenTheme">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
            </intent-filter>
        </activity>
        <activity
            android:name=".SavedTextsList"
            android:label="@string/saved_texts_list"
            android:launchMode="singleTask"
            android:parentActivityName=".OcrCaptureActivity"
            android:theme="@style/FullscreenTheme">
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value=".OcrCaptureActivity" />
        </activity>

        <!-- todo 5: Add provider to AndroidManifest.xml -->
        <provider
            android:name="com.myapps.documentscanner.data.TextProvider"
            android:authorities="com.myapps.documentscanner" />

        <activity
            android:name=".TextDetailActivity"
            android:label="@string/edit_text_detail"
            android:parentActivityName=".SavedTextsList"
            android:theme="@style/FullscreenTheme">
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value=".SavedTextsList" />
        </activity>

        <activity
            android:name=".FullScreenViewActivity"
            android:label="@string/title_activity_full_image"
            android:theme="@style/FullscreenTheme" />
        <activity
            android:name=".SettingsActivity"
            android:label="@string/settings"
            android:theme="@style/AppTheme" />
        <activity
            android:name=".OcrCaptureActivity"
            android:label="Read Text"
            android:parentActivityName=".DocumentScannerActivity"
            android:theme="@style/AppTheme">
            <!-- The meta-data element is needed for versions lower than 4.1 -->
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value=".DocumentScannerActivity" />
        </activity><!-- ATTENTION: This was auto-generated to add Google Play services to your project for
        App Indexing.  See https://g.co/AppIndexing/AndroidStudio for more information. -->
        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />

    </application>

</manifest>

build.gradle文件如下:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23

    buildToolsVersion '23.0.2'
    defaultConfig {
        applicationId "com.myapps.documentscanner"
        minSdkVersion 21
        targetSdkVersion 23
        versionCode 3
        versionName '2.0'
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

            signingConfig signingConfigs.config
        }
    }
    splits {

        // Configures multiple APKs based on ABI.
        abi {

            // Enables building multiple APKs per ABI.
            enable true

            // By default all ABIs are included, so use reset() and include to specify that we only
            // want APKs for x86, armeabi-v7a, and mips.

            // Resets the list of ABIs that Gradle should create APKs for to none.
            reset()

            // Specifies a list of ABIs that Gradle should create APKs for.
            include "x86", "armeabi-v7a", "mips" , 'armeabi'

            // Specifies that we do not want to also generate a universal APK that includes all ABIs.
            universalApk false
        }
    }

}

// Map for the version code that gives each ABI a value.
ext.abiCodes = ['armeabi':1, 'armeabi-v7a':2, mips:3, x86:4]

// For per-density APKs, create a similar map like this:
// ext.densityCodes = ['mdpi': 1, 'hdpi': 2, 'xhdpi': 3]

import com.android.build.OutputFile

// For each APK output variant, override versionCode with a combination of
// ext.abiCodes * 1000 + variant.versionCode. In this example, variant.versionCode
// is equal to defaultConfig.versionCode. If you configure product flavors that
// define their own versionCode, variant.versionCode uses that value instead.
android.applicationVariants.all { variant ->

    // Assigns a different version code for each output APK
    // other than the universal APK.
    variant.outputs.each { output ->

        // Stores the value of ext.abiCodes that is associated with the ABI for this variant.
        def baseAbiVersionCode =
                // Determines the ABI for this variant and returns the mapped value.
                project.ext.abiCodes.get(output.getFilter(OutputFile.ABI))

        // Because abiCodes.get() returns null for ABIs that are not mapped by ext.abiCodes,
        // the following code does not override the version code for universal APKs.
        // However, because we want universal APKs to have the lowest version code,
        // this outcome is desirable.
        if (baseAbiVersionCode != null) {

            // Assigns the new version code to versionCodeOverride, which changes the version code
            // for only the output APK, not for the variant itself. Skipping this step simply
            // causes Gradle to use the value of variant.versionCode for the APK.
            output.versionCodeOverride =
                    baseAbiVersionCode * 1000 + variant.versionCode
        }
    }
}

repositories {
    maven { url "https://jitpack.io" }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.3.0'
    compile 'com.android.support:design:23.3.0'
    compile 'com.google.zxing:core:3.0.1'
    compile 'com.android.support:support-v4:23.3.0'
    compile 'com.afollestad:drag-select-recyclerview:0.3.6'
    compile 'com.github.nostra13:Android-Universal-Image-Loader:v1.9.5'
    compile 'com.github.fafaldo:fab-toolbar:1.2.0'
    compile 'com.google.android.gms:play-services-analytics:9.2.1'
    compile 'com.google.android.gms:play-services-vision:9.2.1'
    compile 'com.google.android.gms:play-services-appindexing:9.2.1'
    compile project(':openCVLibrary310')
}

apply plugin: 'com.google.gms.google-services'

错误是:错误:无法从E:\ Document-Scanner-master \ src \ main \ AndroidManifest.xml读取packageName

0 个答案:

没有答案