I am getting an error while running my code.
Error:
Launching lib\main.dart on Android SDK built for x86 in debug mode...
C:\Users\emiry\Desktop\KelimeOgren\kelimeogrenmeuygulamasi\android\app\src\debug\AndroidManifest.xml Error:
uses-sdk:minSdkVersion 18 cannot be smaller than version 19 declared in library [com.google.firebase:firebase-messaging:23.0.0] C:\Users\emiry\.gradle\caches\transforms-2\files-2.1\04fa4caba5dd20f8583ef52f1aeef9ee\jetified-firebase-messaging-23.0.0\AndroidManifest.xml as the library might be using APIs not available in 18
Suggestion: use a compatible library with a minSdk of at most 18,
or increase this project's minSdk version to at least 19,
or use tools:overrideLibrary="com.google.firebase.messaging" to force usage (may lead to runtime failures)
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugMainManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 18 cannot be smaller than version 19 declared in library [com.google.firebase:firebase-messaging:23.0.0] C:\Users\emiry\.gradle\caches\transforms-2\files-2.1\04fa4caba5dd20f8583ef52f1aeef9ee\jetified-firebase-messaging-23.0.0\AndroidManifest.xml as the library might be using APIs not available in 18
Suggestion: use a compatible library with a minSdk of at most 18,
or increase this project's minSdk version to at least 19,
or use tools:overrideLibrary="com.google.firebase.messaging" to force usage (may lead to runtime failures)
* 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
BU�LD FAILED in 10s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
main.dart:
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:kelimeogrenmeuygulamasi/arayuzEkrani.dart';
import 'package:onesignal_flutter/onesignal_flutter.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
Firebase.initializeApp();
OneSignal.shared.setAppId("APP-ID");
runApp(mainApp());
}
class mainApp extends StatelessWidget {
const mainApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
home: arayuz(),
);
}
}
mentioned AndroidManifest.xml
file:
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2012 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.google.firebase.messaging" >
<uses-sdk android:minSdkVersion="19" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<!-- Required by older versions of Google Play services to create IID tokens -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<application>
<receiver
android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</receiver>
<!--
FirebaseMessagingService performs security checks at runtime,
but set to not exported to explicitly avoid allowing another app to call it.
-->
<service
android:name="com.google.firebase.messaging.FirebaseMessagingService"
android:directBootAware="true"
android:exported="false" >
<intent-filter android:priority="-500" >
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<service
android:name="com.google.firebase.components.ComponentDiscoveryService"
android:exported="false" >
<meta-data
android:name="com.google.firebase.components:com.google.firebase.messaging.FirebaseMessagingRegistrar"
android:value="com.google.firebase.components.ComponentRegistrar" />
</service>
</application>
</manifest>
My purpose is to send notification to phone with OneSignal. I have placed the error and the contents of the mentioned files above.
As a guide I used it here: https://dev.to/lordlamee/implementing-push-notifications-with-flutter-and-onesignal-part-1-3690. And I did the same procedure here.
What is the problem? How can I solve it?
Last mistake:
Launching lib\main.dart on Android SDK built for x86 in debug mode...
e: C:/Users/emiry/.gradle/caches/transforms-2/files-2.1/1e3435b9bf2a9d121ad7aaa0ead8e64e/work-runtime-2.7.1-api.jar!/META-INF/work-runtime_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugKotlin'.
> Compilation error. See log for more 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
BU�LD FAILED in 27s
[!] Your project requires a newer version of the Kotlin Gradle plugin.
Find the latest version on https://kotlinlang.org/docs/gradle.html#plugin-and-versions, then update C:\Users\emiry\Desktop\KelimeOgren\kelimeogrenmeuygulamasi\android\build.gradle:
ext.kotlin_version = '<latest-version>'
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
Second error I get:
Launching lib\main.dart on Android SDK built for x86 in debug mode...
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\emiry\Desktop\KelimeOgren\kelimeogrenmeuygulamasi\android\app\build.gradle' line: 74
* What went wrong:
A problem occurred evaluating project ':app'.
> path may not be null or empty string. path='null'
* 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
BU�LD FAILED in 24s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
CodePudding user response:
Go to your project's root path/android/app/build.gradle
then inside the android -> defaultConfig
block set the minSdkVersion to 19/21
like the below code.
defaultConfig {
applicationId "com.*****.*****"
minSdkVersion 21
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}
Re-run the project. I think this will solve your issue.