Reputation: 91
Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. Note: C:\Users\Arslan\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\launch_review-3.0.1\android\src\main\java\com\iyaffle\launchreview\LaunchReviewPlugin.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: C:\Users\Arslan\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\path_provider_android-2.0.12\android\src\main\java\io\flutter\plugins\pathprovider\PathProviderPlugin.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. e: C:\Users\Arslan\AppData\Local\Pub\Cache\hosted\pub.dartlang.org\share_plus-3.1.0\android\src\main\kotlin\dev\fluttercommunity\plus\share\MethodCallHandler.kt: (34, 24): Type mismatch: inferred type is String? but String was expected
FAILURE: Build failed with an exception.
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
BUILD FAILED in 48s Exception: Gradle task assembleDebug failed with exit code 1
Getting this compiling flutter app tried everything flutter clean etc nothing is working.
Upvotes: 7
Views: 9554
Reputation: 495
Just experienced this issue. I solved this by following these steps:
flutter clean
flutter pub get
flutter run
Upvotes: 2
Reputation: 783
I had the same problem today.
The only solution for me, was this.
pubspec.yaml
share_plus
line, and put share_plus: ^4.0.4
(or latest version from pub.devflutter run
Upvotes: 9
Reputation: 461
I had the same problem yesterday, although I do not quite remember how I solved it. Let's try to go through the standard:
I won’t say, but as far as I remember, I had this problem when I used one of the translation plugins, this plugin added an additional translate method to the String object, it was displayed correctly in the code, but when launched it gave an error related to Kotlin. Example:
String text;
print(text.translate); //Error for no apparent reason
So check your code carefully.
Pay special attention to this warning from your error message: "Type mismatch: inferred type is String? but String was expected". Try to find this gap in the newly written functionality.
android/build.gradle:
buildscript {
ext.kotlin_version = '1.6.10'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
// gradle.projectsEvaluated {
// tasks.withType(JavaCompile){
// options.compilerArgs << "-Xlint:deprecation" << "-Xlint:unchecked"
// }
// }
}
allprojects {
repositories {
google()
mavenCentral()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
android/app/build.gradle:
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion flutter.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.legend_application"
minSdkVersion 22 //flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:multidex:1.0.3'
}
Upvotes: 0