i'm trying to develop an app on flutter. My code in the app\ .gradle is:
apply plugin: 'com.google.protobuf'
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 FileNotFoundException("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 32
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.my_firstapp"
minSdkVersion 23
targetSdkVersion 32
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}
buildTypes {
release {
// 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.google.firebase:firebase-analytics:20.1.2'
api 'com.google.firebase:firebase-ml-vision-image-label-model:20.0.2'
implementation 'io.grpc:grpc-protobuf-lite:1.45.1'
}
However it returns me the error:
**Execution failed for task ':app:generateDebugProto'.java.io.IOException: Cannot run program "protoc": CreateProcess error=2 **
What should i do? I've also added classpath in android\ .gradle.
Related
I'm having the following problem with Build.Gradle when I try to build my application:
Launching lib\main.dart on sdk gphone64 x86 64 in debug mode...
Running Gradle task 'assembleDebug'...
FAILURE: Build failed with an exception.
Where: Build file 'C:\Users\mateu\StudioProjects\Coquinha\android\app\build.gradle'
line: 66
What went wrong: A problem occurred evaluating project ':app'.
java.lang.NullPointerException (no error message)
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 2s Exception: Gradle task assembleDebug failed with
exit code 1
Below is my 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"
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
compileSdkVersion flutter.compileSdkVersion
ndkVersion flutter.ndkVersion
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.coquinha"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties ['storeFile'] ? file(keystoreProperties[storeFile]) : null
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
// 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
signingConfig signingConfigs.release
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
Apparently the error is in the part of the code I highlighted below:
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties ['storeFile'] ? file(keystoreProperties[storeFile]) : null
storePassword keystoreProperties['storePassword']
}
}
Remove in users folder '.gardle' and '.android' cache folder. This is my solutions and it works
I decompiled fmradio app for xiaomi. For using hidden api i copyd and replaced android.jar file from https://drive.google.com/drive/folders/185jgOthBI_qXzeS14s795LMGSekSTw5_. I have gradles:
#project
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.3.0' apply false
id 'com.android.library' version '7.3.0' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
#module
plugins {
id 'com.android.application'
}
android {
applicationVariants.all { variant ->
//variant.packageApplicationProvider.get().outputDirectory = new File(project.getRootDir().absolutePath + "/" + variant.buildType.name + "/")
variant.outputs.all { output ->
output.outputFileName = "FMRadio" + (variant.buildType.name.toLowerCase().contains("release") ? "" : "-" + variant.buildType.name) + ".apk"
}
}
signingConfigs {
release {
def f = file("../local.properties")
if (f.exists()) {
def props = new Properties()
f.withInputStream { props.load(it) }
storeFile file(props.RELEASE_KEY_PATH)
storePassword props.RELEASE_STORE_PASSWORD
keyAlias props.RELEASE_KEY_ALIAS
keyPassword props.RELEASE_KEY_PASSWORD
} else {
def writer = new FileWriter(f.path)
writer.write("RELEASE_KEY_PATH=\n")
writer.write("RELEASE_KEY_PASSWORD=\n")
writer.write("RELEASE_KEY_ALIAS=\n")
writer.write("RELEASE_STORE_PASSWORD=")
writer.close()
throw new IOException("File $f.name was created. please fill it by values of your release key.")
}
}
}
compileSdkVersion 30
buildToolsVersion "33.0.0"
defaultConfig {
applicationId 'com.miui.fmservice'
minSdkVersion 30
targetSdkVersion 31
versionCode 30
versionName "11"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
lintOptions {
abortOnError false
checkReleaseBuilds false
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'androidx.fragment:fragment:1.5.3'
}
But after trying to sync project with gradle files i get a large error stack trace,which you can find at https://pastebin.com/PfeN1viv. Help me please why this error happens. May be in android 30 i can't use hidden api? Thanks everybody for any help.
When compiling project(build apk) it returns error:
e: C:\Users\1\FlutterSDK\flutter\.pub-cache\hosted\pub.dartlang.org\rtmp_publisher-0.3.7\android\src\main\kotlin\com\app\rtmp_publisher\Camera.kt: (634, 49): Unresolved reference: startStream
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':rtmp_publisher:compileReleaseKotlin'.
> 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
Version Kotlin is relevant
Gradle file android\build.gradle:
buildscript {
ext.kotlin_version = '1.5.10'
repositories {
google()
jcenter()
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
classpath 'com.android.tools.build:gradle:4.2.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Gradle file 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 FileNotFoundException("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"
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
compileSdkVersion 30 // was 28
// added for rtmp
packagingOptions {
exclude 'project.clj'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "youinroll.com"
minSdkVersion 23
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
versionCode 3
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
shrinkResources false
minifyEnabled false
}
}
allprojects {
repositories {
google()
mavenCentral()
maven{url "https://storage.googleapis.com/download.flutter.io"}
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
The application has broadcast using the phone-camera, the problem is in it.
Apparently problem is in connectimg java and kotlin.
Updating and deleting flutter/gradle perfomed.
I faced this exact same issue after upgrading the project and gradle settings.
I managed to fix this by reducing kotlin version to
ext.kotlin_version = '1.3.50'
This started giving code compiling issue, for this, I removed this line from build.gradle file
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
I am getting this error in the terminal, I am looking to release the app in internal testing mode on play store, when i was building it in degub mode it was fine, but play store doesn't accept releases in debug mode, so I change configuration and signed the app to build in release mode
PS C:\Users\Ahmed\mobile-app> flutter build apk
Building without sound null safety
For more information see https://dart.dev/null-safety/unsound-null-safety
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\Ahmed\mobile-app\android\app\build.gradle' line: 31
* What went wrong:
A problem occurred evaluating project ':app'.
> Malformed \uxxxx encoding.
* 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 2s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 3.5s
Gradle task assembleRelease failed with exit code 1
This is my build.gradle file
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 = '2'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0.2'
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
compileSdkVersion 30
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.mylo.donation_yoga"
minSdkVersion 29
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
I think something is wrong with your "keystorePropertiesFile". You need to check the file path of the Keystore file in it.
For Example, Replace all the backslash with the forward-slash and it should work because as you told the problem comes only when you do the release so it has to be something wrong in the "keystorePropertiesFile".
I am using cloud firestore in my flutter app, Now I am getting this error
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
Here is my gradle.build file
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 from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 27
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.datacollectorsecond"
minSdkVersion 21
targetSdkVersion 27
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
// 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 'com.android.support:multidex:1.0.3'
configurations.all {
resolutionStrategy {
force 'com.google.android.gms:play-services-places:11.8.0'
force 'com.google.android.gms:play-services-location:11.8.0'
}
}
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation ('com.google.android.gms:play-services-places:11.8.0') {
force = true
}
implementation ('com.google.android.gms:play-services-location:11.8.0') {
force = true
}
}
I am getting this error:
Note: /Users/apple/Desktop/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core-0.2.5+1/android/src/main/java/io/flutter/plugins/firebase/core/FirebaseCorePlugin.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
It was working fine before a week, now it is showing error, but when I remove cloud_firesotore, it start working