1. During the development of the flutter plug-in, when opening the Android project of the plug-in and preparing to write the native code, we found that all kinds of reports were red, the code could not jump, and the experience was very bad
The main reason is that the Android project does not rely on the flutter library and uses the local.properties In flutter.sdk Path to load
sdk.dir=C :/Users/11/AppData/Local/Android/ Sdkflutter.sdk=C :\src\flutter\flutter_ windows_ 1.22.6-stable\flutter
Finally, we’re on Android/ build.gradle File, write read flutter.sdk Finally, use compileonly files to rely on the local flutter library.
//Get the local.properties configuration file
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
//Get the sdk path of flutter
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.")
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
compileOnly files("$flutterRoot/bin/cache/artifacts/engine/android-arm/flutter.jar")
compileOnly 'androidx.annotation:annotation:1.1.0'
}
The new sync gradle is effective.
Read More:
- Flutter FAQ-Error retrieving device properties for ro.product.cpu.abi
- [Solved] Idea Failed to recognize Maven and Project Error
- How to Fix log4j2 warning: warn unable to identify org.fusesource.jansi.WindowsAnsiOutputStream
- How to Fix Error Caused by: java.util.MissingResourceException: Can‘t find bundle for base name xxx, locale zh_CN
- Mybatis single parameter pass in exception (How to Fix)
- How to Fix “DevTools failed to load SourceMap” Warning
- [Solved] spring source code compile error: target package does not exist
- How to Fix COM Surrogate has stopped working in Windows 7
- How to Fix flink OutputTag Error
- Caused by: java.lang.IllegalStateException (How to Fix)
- IDEA springboot can recognize POM files, but suddenly it can’t reference mven dependencies. Strange things, inexplicable solutions
- How to Download File via Response (Example Code)
- Idea unified setting code to UTF-8 code and solution of Tomcat garbled code
- IDEA-Error java error release version 5 not supported (How To Fix)
- How to Solve SSM JSON Chinese Messy Code Issue
- How to Solve IBM MQ Connect Error Code 2035
- Android activity Fail to Switch to androidx AppCompatActivity Error
- [Solved] Android Could not determine artifacts for XXXX: Skipped due to earlier error
- Android solution Java.util.concurrent.ExecutionException: com.Android.ide.common.process.ProcessException: exception
- [Integrate the mobile MAS SMS service] SDK start error: NoSuchMethodError: org.springframework.core.annotation.AnnotatedElementUtil