skip to Main Content

As the title says, i have a problem to the recently targetSDK 31.When i was on targetSDK 30 or lower i have never had a problem. I tried many solutions that i found online with no luck. Below are some of my project’s files.

My Manifest file

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="warp.ly.demo">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    <uses-permission android:name="android.permission.BLUETOOTH" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="com.google.android.c2dm.permission.SEND" />

    <!--  Restrict Tablets  -->
    <!--    <supports-screens-->
    <!--        android:largeScreens="true"-->
    <!--        android:normalScreens="true"-->
    <!--        android:smallScreens="true"-->
    <!--        android:xlargeScreens="false" />-->

    <!--    tools:node="replace"-->
    <application
        android:name="warp.ly.demo.WarplyDemoApplication"
        android:allowBackup="false"
        android:exported="false"
        android:extractNativeLibs="true"
        android:fullBackupContent="false"
        android:hardwareAccelerated="true"
        android:icon="@drawable/ic_notification_logo"
        android:installLocation="internalOnly"
        android:label="@string/app_name"
        android:largeHeap="true"
        android:theme="@style/AppTheme">

        <!-- For Huawei Push -->
        <meta-data
            android:name="push_kit_auto_init_enabled"
            android:value="true" />

        <meta-data
            android:name="com.huawei.hms.client.channel.androidMarket"
            android:value="false" />

        <activity
            android:name="warp.ly.demo.activities.SplashActivity"
            android:exported="true"
            android:label="@string/app_name"
            android:screenOrientation="portrait">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

        <activity
            android:name=".activities.MainActivity"
            android:label="@string/title_activity_main"
            android:screenOrientation="portrait" />

        <activity
            android:name=".activities.InboxActivity"
            android:screenOrientation="portrait" />

        <activity
            android:name="ly.warp.sdk.activities.WarpViewActivity"
            android:label=""
            android:screenOrientation="portrait" />

        <activity
            android:name="ly.warp.sdk.dexter.PermissionsActivity"
            android:launchMode="singleInstance"
            android:screenOrientation="portrait"
            android:theme="@android:style/Theme.Light.NoTitleBar" />

        <!-- Service used for updating user's location. -->
        <service
            android:name="ly.warp.sdk.services.UpdateUserLocationService"
            android:exported="false"
            android:permission="android.permission.BIND_JOB_SERVICE" />

        <service
            android:name="ly.warp.sdk.services.WarplyBeaconsRangingService"
            android:exported="false" />

        <!-- Service used for in app notification. -->
        <service
            android:name="ly.warp.sdk.services.WarpInAppNotificationService"
            android:exported="false" />

        <!-- Service used for handling Huawei Push Notifications, comment if we are in Google build -->
        <service
            android:name="ly.warp.sdk.services.HMSBaseMessagingService"
            android:exported="false">
            <intent-filter>
                <action android:name="com.huawei.push.action.MESSAGING_EVENT" />
            </intent-filter>
        </service>

        <!-- FCM Service for push notifications -->
        <service
            android:name="ly.warp.sdk.services.FCMBaseMessagingService"
            android:exported="false">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
        </service>

        <receiver
            android:name="ly.warp.sdk.receivers.LocationChangedReceiver"
            android:exported="false" />

        <receiver
            android:name="ly.warp.sdk.receivers.ConnectivityChangedReceiver"
            android:exported="false">
            <intent-filter>
                <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
                <category android:name="warp.ly.demo" />
            </intent-filter>
        </receiver>

        <receiver
            android:name="ly.warp.sdk.receivers.BluetoothStateChangeReceiver"
            android:exported="false">
            <intent-filter>
                <action android:name="android.bluetooth.adapter.action.STATE_CHANGED" />
            </intent-filter>
        </receiver>

        <receiver
            android:name="ly.warp.sdk.receivers.WarplyInAppNotificationReceiver"
            android:exported="false" />
    </application>

    <!-- For Huawei Push, only if we targetSdkVersion 30, comment if we are in Google build -->
    <!--    <queries>-->
    <!--        <intent>-->
    <!--            <action android:name="com.huawei.hms.core.aidlservice" />-->
    <!--        </intent>-->
    <!--    </queries>-->
</manifest>

My app -> build.gradle file

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.huawei.agconnect'

android {
    compileSdkVersion 31
    buildToolsVersion "31.0.0"

    defaultConfig {
        applicationId "warp.ly.demo"
        minSdkVersion 23
        targetSdkVersion 31
        versionCode 100
        versionName "1.0.0"
    }

    lintOptions {
        checkReleaseBuilds false
        // Or, if you prefer, you can continue to check for errors in release builds,
        // but continue the build even when errors are found:
        abortOnError false
    }

    signingConfigs {
        config {
            // Set the parameters based on the actual signing information.
            keyAlias 'warplydemo'
            keyPassword 'warplydemo'
            storeFile file('../keystore/warplydemo.jks')
            storePassword 'warplydemo'
        }
    }

    buildTypes {
        debug {
            signingConfig signingConfigs.config
        }
        release {
            signingConfig signingConfigs.config
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation project(':libraries:warply_android_sdk')

    //Support
    implementation 'androidx.appcompat:appcompat:1.4.0' //1.4.0 if targetSDK is 31 else 1.3.1
    implementation 'androidx.recyclerview:recyclerview:1.2.1'
    implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'

    implementation 'org.altbeacon:android-beacon-library:2.19.3'
    implementation 'com.squareup.picasso:picasso:2.5.2'

    // Huawei SDK
    implementation 'com.huawei.agconnect:agconnect-core:1.6.2.300'

}

My library’s app -> build.gradle file

apply plugin: 'com.android.library'

android {

    compileSdkVersion 31
    buildToolsVersion "31.0.0"

    defaultConfig {
        minSdkVersion 23
        targetSdkVersion 31
    }
    lintOptions {
        abortOnError false
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }

    useLibrary 'org.apache.http.legacy'
}

dependencies {
    //------------------------------ Support -----------------------------//
    implementation 'androidx.appcompat:appcompat:1.4.0' //1.4.0 if targetSDK is 31 else 1.3.1
    implementation 'androidx.recyclerview:recyclerview:1.2.1'
    implementation 'androidx.cardview:cardview:1.0.0'

    implementation 'org.altbeacon:android-beacon-library:2.19.3'
    implementation 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
    implementation "commons-logging:commons-logging:1.2"

    //------------------------------ Firebase -----------------------------//
    implementation platform('com.google.firebase:firebase-bom:29.0.3')
    implementation 'com.google.firebase:firebase-messaging'

    //------------------------------ GMS -----------------------------//
    implementation 'com.google.android.gms:play-services-base:18.0.1'

    //------------------------------ Work Manager -----------------------------//
    implementation 'androidx.work:work-runtime:2.7.1' //2.7.1 if targetSDK is 31 else 2.6.0

    //------------------------------ Glide -----------------------------//
    implementation 'com.github.bumptech.glide:glide:4.12.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'

    //------------------------------ Huawei -----------------------------//
    implementation 'com.huawei.hms:push:5.1.1.301'
    implementation 'com.huawei.hms:ads-identifier:3.4.39.302'

    //------------------------------ SQLCipher -----------------------------//
    implementation 'net.zetetic:android-database-sqlcipher:4.4.3@aar'
    implementation "androidx.sqlite:sqlite:2.2.0" //2.2.0 if targetSDK is 31 else 2.0.1
}

// In every export please update the version number
task deleteJarLibrary(type: Delete) {
    delete 'jar/warply_android_sdk_v4.5.0.jar'
}

//from('build/intermediates/compile_library_classes/release/')

//Old version
// Gradle Tasks -> warply_android_sdk -> Tasks -> other -> createJarLibrary
//task createJarLibrary(type: Copy) {
//    from fileTree('build/intermediates/bundles/release/')
//    into('jar/')
//    include('classes.jar')
//    rename('classes.jar', 'warply_android_sdk_v4.4.2.jar')
//}

// New version
// Gradle Tasks -> warply_android_sdk -> Tasks -> other -> createFullJarRelease
// When finished it copies tha .jar into
// warply_android_sdk -> build -> intermediates -> full_jar -> release -> createFullJarRelease

task createJarLibrary(type: Jar, dependsOn: 'assembleRelease') {
    from fileTree('build/intermediates/bundles/release/')
}

createJarLibrary.dependsOn(deleteJarLibrary, build)

My Merged Manifest

enter image description here

I have tried every solution i found here or in google. Thanks in advance!

2

Answers


  1. Chosen as BEST ANSWER

    After so many hours of trial and error i found the source of the problem. It was some receivers from huawei push kit library that didn't have the exported property. I updated it to the newest version and my project built just fine.

    Latest version of the Huawei PushKit

    implementation 'com.huawei.hms:push:6.1.0.300'
    

  2. I sew you have 5 activities and only the first activity has the following attribute.

    android:exported="true"
    

    Just try adding this attribute to the rest of the activities in your Manifest.

    <activity
                android:name=".activities.MainActivity"
                android:label="@string/title_activity_main"
                android:exported="true"
                android:screenOrientation="portrait" />
    
            <activity
                android:name=".activities.InboxActivity"
                android:exported="true"
                android:screenOrientation="portrait" />
    
            <activity
                android:name="ly.warp.sdk.activities.WarpViewActivity"
                android:label=""
                android:exported="true"
                android:screenOrientation="portrait" />
    
            <activity
                android:name="ly.warp.sdk.dexter.PermissionsActivity"
                android:launchMode="singleInstance"
                android:screenOrientation="portrait"
                android:exported="true"
                android:theme="@android:style/Theme.Light.NoTitleBar" />
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search