Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build against Android 30 SDK Fails #410

Closed
pgiacomo69 opened this issue Oct 11, 2021 · 19 comments
Closed

Build against Android 30 SDK Fails #410

pgiacomo69 opened this issue Oct 11, 2021 · 19 comments
Labels
Android Android-specific ticket bug Something isn't working

Comments

@pgiacomo69
Copy link

pgiacomo69 commented Oct 11, 2021

Build against Android 30 SDK Fails

To Reproduce
Steps to reproduce the behavior:

  1. Upgrade Package to 5.0.0 in project
  2. Build Against SDK 30, with minimum sdk 24
  3. Build fails with this message:
Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:bundleGooglePlayReleaseResources'.
> A failure occurred while executing com.android.build.gradle.internal.res.Aapt2ProcessResourcesRunnable
   > Android resource linking failed
     ERROR:D:\Flutter\........\build\app\intermediates\bundle_manifest\googlePlayRelease\AndroidManifest.xml:35: AAPT: error: attribute android:usesPermissionFlags not found.
@pgiacomo69 pgiacomo69 changed the title Build against Anroid 30 SDK Fails Build against Android 30 SDK Fails Oct 11, 2021
@Taym95
Copy link
Collaborator

Taym95 commented Oct 11, 2021

I dont think this is a library issue, you are having an Android resource linking failed issue, can you build our example app and check if you get this issue?

@pgiacomo69
Copy link
Author

Ok, later I can try. But yesterday I tried also to build my app against sdk 31 ad it worked. This is strange, it seems like this attribute works only with latest SDK, and it should not be included in manifest when building for SDK 30.
Obviously, using the package version 4.0.1, the app is built normally.

@Taym95
Copy link
Collaborator

Taym95 commented Oct 11, 2021

error: attribute android:usesPermissionFlags not found, you should not add API 31+ permissions to app on API30, example:
<uses-permission android:name="android.permission.BLUETOOTH_SCAN"android:usesPermissionFlags="neverForLocation" /> works only on API >= 31

@pgiacomo69
Copy link
Author

error: attribute android:usesPermissionFlags not found, you should not add API 31+ permissions to app on API30, example: <uses-permission android:name="android.permission.BLUETOOTH_SCAN"android:usesPermissionFlags="neverForLocation" /> works only on API >= 31

Yes, but this line comes from package

@PieterAelse
Copy link
Collaborator

android:usesPermissionFlags="neverForLocation" is added to the Manifest of the Example app (see link), but it is not setup in our package, see the manifest.xml here.

So @pgiacomo69 are you sure you didn't set it up yourself in your manifest file?

@pgiacomo69
Copy link
Author

pgiacomo69 commented Oct 11, 2021

No way, this is my manifest:

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="it.seleuco.unical_cr_app">
	<uses-feature android:name="android.hardware.bluetooth"/>
	<uses-permission android:name="android.permission.BLUETOOTH"/>
	<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
	<!-- <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
	<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> -->
	<uses-permission android:name="android.permission.INTERNET"/>
	<application android:label="My App" android:icon="@mipmap/ic_launcher">
		<activity android:name=".MainActivity" android:exported="true" android:launchMode="singleTop" android:theme="@style/LaunchTheme" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:hardwareAccelerated="true" android:windowSoftInputMode="adjustResize">
			<!-- Specifies an Android theme to apply to this Activity as soon as
                 the Android process has started. This theme is visible to the user
                 while the Flutter UI initializes. After that, this theme continues
                 to determine the Window background behind the Flutter UI. -->
			<meta-data android:name="io.flutter.embedding.android.NormalTheme" android:resource="@style/NormalTheme"/>
			<!-- Displays an Android View that continues showing the launch screen
                 Drawable until Flutter paints its first frame, then this splash
                 screen fades out. A splash screen is useful to avoid any visual
                 gap between the end of Android's launch screen and the painting of
                 Flutter's first frame. -->
			<meta-data android:name="io.flutter.embedding.android.SplashScreenDrawable" android:resource="@drawable/launch_background"/>
			<intent-filter>
				<action android:name="android.intent.action.MAIN"/>
				<category android:name="android.intent.category.LAUNCHER"/>
			</intent-filter>
		</activity>
		<!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
		<meta-data android:name="flutterEmbedding" android:value="2"/>
	</application>
	
</manifest>

@remonh87
Copy link
Contributor

remonh87 commented Oct 11, 2021

@PieterAelse I can confirm the issue. Just create an example app, add reactive ble and you see it. What Android is doing is adding the following in the merged manifest:

    <uses-permission
        android:name="android.permission.BLUETOOTH_SCAN"
        android:usesPermissionFlags="neverForLocation" />

🤦

@remonh87 remonh87 added Android Android-specific ticket bug Something isn't working labels Oct 11, 2021
@pgiacomo69
Copy link
Author

@PieterAelse I can confirm the issue. Just create an example app, add reactive ble and you see it. What Android is doing is adding the following in the merged manifest:

    <uses-permission
        android:name="android.permission.BLUETOOTH_SCAN"
        android:usesPermissionFlags="neverForLocation" />

🤦

Yessssss, now I was going crazy searching in other Packages

@Taym95
Copy link
Collaborator

Taym95 commented Oct 11, 2021

I managed to make it work by adding tools:node="remove" to:

 <uses-permission
            android:name="android.permission.BLUETOOTH_SCAN"
            android:usesPermissionFlags="neverForLocation" tools:node="remove" />

don't forgot to add xmlns:tools="http://schemas.android.com/tools" in the top of your manifest.

@remonh87 If this is okay I can add it as doc in readme!

@pgiacomo69
Copy link
Author

pgiacomo69 commented Oct 11, 2021

I managed to make it work by adding tools:node="remove" to:

 <uses-permission
            android:name="android.permission.BLUETOOTH_SCAN"
            android:usesPermissionFlags="neverForLocation" tools:node="remove" />

don't forgot to add xmlns:tools="http://schemas.android.com/tools" in the top of your manifest.

@remonh87 If this is okay I can add it as doc in readme!

But this should be used only with sdk<31?
I’m curious to understand why this attribute is automagically set in sdk 30, and by who?

@Taym95
Copy link
Collaborator

Taym95 commented Oct 11, 2021

I managed to make it work by adding tools:node="remove" to:

 <uses-permission
            android:name="android.permission.BLUETOOTH_SCAN"
            android:usesPermissionFlags="neverForLocation" tools:node="remove" />

don't forgot to add xmlns:tools="http://schemas.android.com/tools" in the top of your manifest.
@remonh87 If this is okay I can add it as doc in readme!

But this should be used only with sdk<31? I’m curious to understand why this attribute is automagically set in sdk 30, and by who?

Yes should be used only with sdk<31

@remonh87
Copy link
Contributor

yep that works for me lets do this! thanks @Taym95 . 🎉

@safield
Copy link
Contributor

safield commented Oct 18, 2021

I have this same problem. What is the correct course of action? Is there a fix incoming?

@Taym95
Copy link
Collaborator

Taym95 commented Oct 18, 2021

I have this same problem. What is the correct course of action? Is there a fix incoming?

The solution in mentioned in the PR and in the comment above 👆

@YellowShark
Copy link

you should set Android SDK 31

@farr64
Copy link

farr64 commented Oct 21, 2021

@YellowShark mentioned:

you should set Android SDK 31

Would this be a more fundamental solution? After all, flutter doctor asserts:

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)

@remonh87
Copy link
Contributor

@farr64 not sure if I understand your question but you can build the latest version against both SDK31 and 30. In the readme we provided instructions how to do this.

@farr64
Copy link

farr64 commented Oct 21, 2021

Yes, your instructions are clear.

The question is what default SDK you should choose. Apparently, you chose SDK30. So, the question is why not choose SDK31 as your default.

Thanks, @remonh87

@Thidiyas3d
Copy link

I managed to make it work by adding tools:node="remove" to:

 <uses-permission
            android:name="android.permission.BLUETOOTH_SCAN"
            android:usesPermissionFlags="neverForLocation" tools:node="remove" />

don't forgot to add xmlns:tools="http://schemas.android.com/tools" in the top of your manifest.
@remonh87 If this is okay I can add it as doc in readme!

But this should be used only with sdk<31? I’m curious to understand why this attribute is automagically set in sdk 30, and by who?

Yes should be used only with sdk<31

Thanks @Taym95

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Android Android-specific ticket bug Something isn't working
Projects
None yet
Development

No branches or pull requests

8 participants