flutter-permission-handler
flutter-permission-handler copied to clipboard
Execution failed for task ':permission_handler_android:compileDebugJavaWithJavac'.
🐛 Bug Report
error: warnings found and -Werror specified 1 error
FAILURE: Build failed with an exception.
- What went wrong: Execution failed for task ':permission_handler_android:compileDebugJavaWithJavac'.
Compilation failed; see the compiler error output for details.
Expected behavior
Should compile
Reproduction steps
Run flutter run
Configuration
Version: 9.2.0
Platform:
- [ ] :iphone: iOS
- [ X] :robot: Android
I resolved the issue. Change your compile and targeted version to 33 Solution 1
compileSdkVersion 33
defaultConfig {
minSdkVersion 21
targetSdkVersion 33
...
}
Solution 2 downgrade permissin_handler to 9.2.0
You should up your compileSdkVersion to 33
你应该把你的 compileSdkVersion 提高到 33
But another one need 31,how can I solve this problem?
你应该把你的 compileSdkVersion 提高到 33
But another one need 31,how can I solve this problem?
Update your pub dev
flutter pub upgrade
You should up your compileSdkVersion to 33
it worked
@Saddi993 I am facing the same issue, I have compileSdkVersion 33
@strmchsr,
What version of the permission handler are you using?
I came into the same issue with permission_handler 9.0.2+1
Hi, I have the same issue with permission_handler: ^10.4.0
. It works fine when building the app (I see no errors), but it throws when trying to run integration tests using Patrol.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':permission_handler_android:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
We have these sdk settings: compileSdkVersion 33
, minSdkVersion 23
, targetSdkVersion 33
.
Update: I uninstalled openjdk (20) and installed openjdk@11 and it seems to work now. 🤔
(10.4.2) ('com.android.tools.build:gradle:7.4.2') (distributionUrl=https://services.gradle.org/distributions/gradle-7.5-bin.zip)
in my case compileSdkVersion 33 still not working build pass on Android Platform everything seems fine, but flutter runs into error: "Execution failed for task ':permission_handler_android:compileDebugJavaWithJavac'."
update: upgrade flutter to 3.7.7 solved
Closing this issue as these are all related to local environment. Things to verify are:
- Make sure the environment uses JDK 11 or higher.
- Make sure the
compileSdkVersion
is set to33
in theandroid/app/build.gradle
file.
If this still causes problems, please file a new bug with complete log output by running the flutter build apk -v
(or flutter build appbundle -v
when build an Android application bundle).
@kashiflab Currently, I can successfully compile and build an APK for my Flutter application without encountering any issues. However, as soon as I include the 'permission_handler' package, I am unable to do so. I have tried using multiple versions of the 'permission_handler' package, and compileSdkVersion 33 targetSdkVersion 33 but the problem persists. The error message I receive is as follows:
error: warnings found and -Werror specified
FAILURE: Build failed with an exception.
- What went wrong: Execution failed for task ':permission_handler_android:compileDebugJavaWithJavac'.
Compilation failed; see the compiler error output for details.
@essyty can you please tell me which 'permission_handler' version are you using?
@essyty can you please tell me which 'permission_handler' version are you using?
The last version, 10.4.3, and i tried other versions
@essyty Please double-check the documentation of the permission handler maybe you are missing some steps
The TL;DR version is:
Add the following to your "gradle.properties" file: android.useAndroidX=true android.enableJetifier=true
Make sure you set the compileSdkVersion in your "android/app/build.gradle" file to 33: android { compileSdkVersion 33 ... }
Also upgrade flutter
i ll add this 2 lines and i see android.useAndroidX=true android.enableJetifier=true everything else is correct
Hi @essyty,
The problem seems to be related to the -Werror
switch the permission_handler
includes in it's build.gradle file.
Basically this switch makes sure the code only compiles when the build process doesn't throw any warnings. I think this switch populates to the whole application and doesn't solely stick to the permission_handler plugin alone.
In hindsight this is a bit to restrictive and developers/ companies should be able to determine themselves how to threat warnings. Therefore I will release a new version where I will remove the -Werror
switch and move it into our example application. This way we will still make sure warning will be treated as errors when the CI builds the example application. However, consumers of the permission_handler plugin will not inherit this setting and should be able to configure it for themselves.
I will inform you here when the new build is ready. Would be great if you'd be able to confirm if it solves the problem.
I changed the java's version installed in my computer from 20 to 11 and i can compil my code now ... i really don't know why. but when i build the apk it does not show me the permission dialog
main.dart : import 'package:flutter/material.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:flutter_web_plugins/url_strategy.dart'; import 'package:provider/provider.dart';
import 'flutter_flow/flutter_flow_theme.dart'; import 'flutter_flow/flutter_flow_util.dart'; import 'flutter_flow/internationalization.dart'; import 'flutter_flow/nav/nav.dart'; import 'index.dart';
void main() async { WidgetsFlutterBinding.ensureInitialized(); usePathUrlStrategy();
await FlutterFlowTheme.initialize();
final appState = FFAppState(); // Initialize FFAppState await appState.initializePersistedState();
runApp(ChangeNotifierProvider( create: (context) => appState, child: MyApp(), )); }
class MyApp extends StatefulWidget { // This widget is the root of your application. @override State<MyApp> createState() => _MyAppState();
static _MyAppState of(BuildContext context) => context.findAncestorStateOfType<_MyAppState>()!; }
class _MyAppState extends State<MyApp> {
Locale? _locale;
ThemeMode _themeMode = FlutterFlowTheme.themeMode;
late AppStateNotifier _appStateNotifier;
late GoRouter _router;
late Future
@override void initState() { super.initState(); _appStateNotifier = AppStateNotifier.instance; _router = createRouter(_appStateNotifier); storagePermissionChecker = checkStoragePermission(); }
Future
Future
void setLocale(String language) { setState(() => _locale = createLocale(language)); }
void setThemeMode(ThemeMode mode) => setState(() { _themeMode = mode; FlutterFlowTheme.saveThemeMode(mode); });
@override Widget build(BuildContext context) { return MaterialApp.router( title: 'GP12', localizationsDelegates: [ FFLocalizationsDelegate(), GlobalMaterialLocalizations.delegate, GlobalWidgetsLocalizations.delegate, GlobalCupertinoLocalizations.delegate, ], locale: _locale, supportedLocales: const [Locale('en', '')], theme: ThemeData(brightness: Brightness.light), darkTheme: ThemeData(brightness: Brightness.dark), themeMode: _themeMode, routerConfig: _router, ); } }
Update : I think the problem in Android 13, i installed the app in device with Android 12 and it's works
@essyty, since you are requesting storage permissions, please carefully read our FAQ on this topic.