Problem with flutter plugin (Image Cropper) - android

I'm creating a app which will work with images, some of them will need to be cropped and some not. I have added the library:
image_cropper: ^1.3.1
I have installed the dependencies in android manifest:
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
// This is wat I had to add as said in the pub.dev from icon cropper
<activity
android:name="com.yalantis.ucrop.UCropActivity"
android:screenOrientation="portrait"
android:theme="#style/Theme.AppCompat.Light.NoActionBar"/>
</application>
</manifest>
But when I run my application I receive the following error:
Launching lib\main.dart on SM N950F in debug mode...
lib\main.dart:1
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Could not resolve com.github.yalantis:ucrop:2.2.7.
Required by:
project :app > project :image_cropper
> Could not resolve com.github.yalantis:ucrop:2.2.7.
> Could not get resource 'https://www.jitpack.io/com/github/yalantis/ucrop/2.2.7/ucrop-2.2.7.pom'.
> Could not GET 'https://www.jitpack.io/com/github/yalantis/ucrop/2.2.7/ucrop-2.2.7.pom'.
> Connect to www.jitpack.io:443 [www.jitpack.io/149.56.28.39] failed: Read timed out
* 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 1m 36s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
This is my settings.gradle:
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
include ':app'
def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
def plugins = new Properties()
def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
if (pluginsFile.exists()) {
pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
}
plugins.each { name, path ->
def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
include ":$name"
project(":$name").projectDir = pluginDirectory
}
I have multiDex enabled too.

I have image_cropper working, an example for you to check and compare if is everything ok.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example">
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:label=""
android:usesCleartextTraffic="true"
android:icon="#mipmap/ic_launcher">
<activity
android:name="com.yalantis.ucrop.UCropActivity"
android:screenOrientation="portrait"
android:theme="#style/Theme.AppCompat.Light.NoActionBar"/>
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="#style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="#style/NormalTheme"
/>
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="#drawable/launch_background"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>

Check if you have a good internet connection and then build the project again

Related

All Activities and layouts got corrupted in Android Studio

I am working on a projects since 3 months. Today most of my activities and xml files got corrupted. I have tried deleting workspace.iml file but it remains same.Local History in VCS is also empty. Is there any way to recover my code or solve this issue.
Note These files are same as previous if I open then in Notepad app/scrc/main/activity.java, but showing different in Android studio
Here what my code looks like now
<component name="libraryTable"> <library name="Gradle: com.google.firebase:firebase-measurement-connector-impl-17.0.3">
<CLASSES>
<root url="file://$USER_HOME$/.gradle/caches/transforms-1/files-1.1/firebase-measurement-connector-impl-17.0.3.aar/fb2536827bf92d82ab72080a9863eb78/res" />
<root url="jar://$USER_HOME$/.gradle/caches/transforms-1/files-1.1/firebase-measurement-connector-impl-17.0.3.aar/fb2536827bf92d82ab72080a9863eb78/jars/classes.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
gradle file:
apply plugin: 'com.android.application'apply plugin: 'com.google.gms.google-services'android {
compileSdkVersion 28
defaultConfig {
applicationId "com.apkfeast.class11walkthrogh"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } }}dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
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.android.support:design:28.0.0'
implementation 'com.github.chrisbanes:PhotoView:2.1.3'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.google.firebase:firebase-database:16.0.5'
implementation 'com.google.firebase:firebase-core:16.0.5'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.github.bumptech.glide:glide:4.8.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
implementation 'com.firebaseui:firebase-ui-database:4.2.1'
implementation 'com.github.bumptech.glide:compiler:4.8.0'
implementation 'com.github.bumptech.glide:annotations:4.8.0'
implementation 'com.firebase:firebase-client-android:2.5.2'
implementation 'com.google.firebase:firebase-storage:16.0.5'
implementation 'com.google.firebase:firebase-auth:16.0.5'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.android.gms:play-services-ads:17.1.1'
implementation 'com.android.support:multidex:1.0.3'}apply plugin: 'com.google.gms.google-services'
Manifest
<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.apkfeast.class11walkthrogh"
android:screenOrientation="portrait" >
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme"
android:fullBackupContent="true">
<activity android:name=".Splash">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-3940256099942544~3347511713"/>
<activity android:name=".Hyderabad" />
<activity android:name=".Mirpurkhas" />
<activity android:name=".SelectBoard" />
<activity android:name=".Quiz" />
<activity android:name=".Notes" />
<activity android:name=".fedral" />
<activity android:name=".sukkur" />
<activity android:name=".larkana" />
<activity android:name=".aghakhan" />
<activity android:name=".sarghoda" />
<activity android:name=".Rawalpindi" />
<activity android:name=".Faisalabad" />
<activity android:name=".Multan" />
<activity android:name=".Gujranwala" />
<activity android:name=".lahore" />
<activity android:name=".karachi" />
<activity android:name=".sahiwal" />
<activity android:name=".dgkhan" />
<activity android:name=".peshawar" />
<activity android:name=".bahawalpur" />
<activity android:name=".balochistan" />
<activity android:name=".hydchem" />
<activity android:name=".hydphy" />
<activity android:name=".hydbio" />
<activity android:name=".hydeng" />
<activity android:name=".hydisl" />
<activity android:name=".hydurd" />
<activity android:name=".hydmat" />
<activity android:name=".hydpak" />
<activity android:name=".hydviewdown" />
<activity android:name=".mpkVD" />
<activity android:name=".fedVD" />
<activity android:name=".sukVD" />
<activity android:name=".larVD" />
<activity android:name=".sarVD" />
<activity android:name=".rawVD" />
<activity android:name=".faiVD" />
<activity android:name=".mulVD" />
<activity android:name=".gujVD" />
<activity android:name=".lahVD" />
<activity android:name=".khiVD" />
<activity android:name=".sahVD" />
<activity android:name=".dgkVD" />
<activity android:name=".pesVD" />
<activity android:name=".bahVD" />
<activity android:name=".balVD" />
<activity android:name=".result" />
<activity android:name=".bioquiz" />
<activity android:name=".chemquiz" />
<activity android:name=".phyquiz" />
<activity android:name=".full" />
</application>
</manifest>
Solved
I have fixed it by deleting all the files in C:\Users\cc.AndroidStudio3.2\system\caches.
I also had the same problem this morning.
I thought this was due to migrating to AndroidX but
It was wrong. It may occur due to improper indexing and building for e.g. the indexing is force stopped. or due to some IDE issues.
The isuue resolved by deleting gradle and .idea folder in project
and clearing cache of Android Studio IDE by D:\Users\ABCD.AndroidStudio3.2\system\caches.
And issue was resolved.
Note:- Please take Project Backups Daily.
Solution for Android studio Arctic Fox and Higher Versions
Steps
Exit Android Studio
Delete caches folder from
C:\Users\{username}\AppData\Local\Google\AndroidStudio2020.3 // For Arctic Fox
Open Android Studio and your code has being Perfect
Check your Android studio version and Target that version folder at below location
C:\Users\{username}\AppData\Local\Google
Note : AppData folder is Hidden in Windows
Erasing the cache of the Android studio will resolve the problem, for that you have to go to:
C:\Users\user\.AndroidStudio3.5\system\caches
(On windows)
and on Mac:
~/.AndroidStudio3.5/system/caches
Delete all the files there and restart the Android studio.
I solved that by
Close project you are working on
//This enables deleting all cache files
Close android studio
navigate to .AndroidStudio folder and then sytem then cache
delete the cache
Go to your project folder delete delete gradle and .idea folder
delete app.iml file too
import project dont open as exixting.
Boom you done.
Delete caches folder of the android studio
Solutions for android studio 3.6 or below android studio 3.6
C:\Users\{user}\.AndroidStudio{version}\system\caches
And above android studio 3.6 or android studio arctic fox
C:\Users\{user}\AppData\Local\Google\AndroidStudio{version}\cache
Close android studio then delete the cache found in
C:\Users\**user**\.AndroidStudio3.6\system\caches
Important not to modify a file before having deleted the android studio cache
If you modify a file you risk not being able to recover your old code
Rename your project folder and delete .gradle and .idea file inside project folder
I am also facing the same issue so i am copy the files from Project location which is corrupted. In my case, there is list of files corrupted due to module added in Login Activity
build.gradle (Project)
build.gradle (App-level)
AndroidManifest.xml
activity_login.xml
ActivityLogin
Steps to solve the problem
I have deleting .iml and .idea file then restart the Android Studio.
Paste the content from Project Location which is corrupted
Commenting the code in which module classes available
Run the application
If you are using git then rollback the changes in corrupted files as copy-paste process as done in Step-2
Above one process is working for me.
It's only a project cache problem (if you see all files in Notepad, it will look fine. No file is corrupt.).
I have 100% working solution.
Close Android Studio
Copy project folder
Rename new project folder
Re-start Android Studio
File->New-> Import from new folder
Delete old folder.

Fighting with Unresolved class in AndroidManifest.xml

When I load up Android Studio and build my project I get a unresolved class in my manifest file.
<activity
android:name="com.google.zxing.client.android.CaptureActivity" //THIS IS WHERE THE ERROR POINTS TO
android:configChanges="orientation|keyboardHidden"
android:screenOrientation="landscape"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
android:windowSoftInputMode="stateAlwaysHidden" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="google.zxing.client.android.SCAN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
I also added its reference to my build.gradle
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:support-v4:28.0.0-rc01'
implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
implementation 'com.journeyapps:zxing-android-embedded:3.0.2#aar'
implementation 'com.google.zxing:core:3.3.2'
//...More dependencies below
}
I have tried cleaning and rebuilding, running my gradle file, restarting Android Studio but I am still getting that unresolved class issue. I believe it might be that CaptureActivity is no longer being used. This is just speculation. I have gone through the android developer site to see if I can find it but no such luck.
EDIT
Iforgot to mention that I first saw this when I ran the code analyze. Analyze->Inspect Code. Its under Android Resource Validation.
UPDATE! Please read
After making this change I seem to have an issue when I clean/rebuild my project
D:\Foo_Workspace\Library Build\Foo\mobile\src\main\AndroidManifest.xml:151:13-50 Error:
Attribute activity#com.journeyapps.barcodescanner.CaptureActivity#screenOrientation value=(landscape) from [:Foo] AndroidManifest.xml:151:13-50
is also present at [com.journeyapps:zxing-android-embedded:3.0.2] AndroidManifest.xml:51:13-56 value=(sensorLandscape).
Suggestion: add 'tools:replace="android:screenOrientation"' to <activity> element at AndroidManifest.xml:148:9-164:20 to override.
D:\Foo_Workspace\Library Build\Foo\mobile\src\main\AndroidManifest.xml:152:13-71 Error:
Attribute activity#com.journeyapps.barcodescanner.CaptureActivity#theme value=(#android:style/Theme.NoTitleBar.Fullscreen) from [:Foo] AndroidManifest.xml:152:13-71
is also present at [com.journeyapps:zxing-android-embedded:3.0.2] AndroidManifest.xml:53:13-54 value=(#style/zxing_CaptureTheme).
Suggestion: add 'tools:replace="android:theme"' to <activity> element at AndroidManifest.xml:148:9-164:20 to override.
:mobile:processDebugManifest
See http://g.co/androidstudio/manifest-merger for more information about the manifest merger.
:mobile:processDebugManifest FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':mobile:processDebugManifest'.
> Manifest merger failed with multiple errors, see logs
* 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
Class in manifest is wrong, change it to
<activity
android:name="com.journeyapps.barcodescanner.CaptureActivity"
android:configChanges="orientation|keyboardHidden"
android:screenOrientation="landscape"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
android:windowSoftInputMode="stateAlwaysHidden"
tools:replace="screenOrientation,android:theme" />
Also Better update gradle dependencies
implementation ('com.journeyapps:zxing-android-embedded:3.6.0') { transitive = false }
implementation 'com.google.zxing:core:3.3.0'

No deviceToken and pushType after upgrading to Parse Android SDK 1.17.3

Since we've upgraded to Parse-SDK-Android 1.17.3 we are experiencing issues with the deviceToken and pushType of the installation objects. They both are undefined after the object's creation. We have also tried to downgrade the sdk to 1.17.0, 1.17.1 and 1.17.2 . It seems that the new ParseFirebaseJobService's onStartJob method is not getting called. The documentation was strictly followed.
Manifest:
<serviceandroid:name="com.parse.fcm.ParseFirebaseInstanceIdService"
android:exported="true">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>
<service android:name="com.parse.fcm.ParseFirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
build.gradle(app) :
implementation 'com.parse:parse-android:1.17.3'
implementation 'com.parse:parse-fcm-android:1.17.3'
build.gradle(project):
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.google.gms:google-services:3.2.1'
}
allprojects {
repositories {
...
google()
}
}
The Parse-Server's version is 2.8.2
Any help would be appreciated.

Unresolved package "generated" in AndroidManifest.xml

In my Android Studio androidManifest.xml file, I found an unresolved package generated. How can I fix it?
The issued code is : android:name=".provider.generated.SquawkProvider
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.aaa">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<provider
android:name=".provider.generated.SquawkProvider"
<!-- shows unresolved package "generated" -->
android:authorities="com.example.android.aaa.provider.provider"
android:exported="false" >
</provider>
<activity
android:name=".following.FollowingPreferenceActivity"
android:parentActivityName=".MainActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity" />
</activity>
<service
android:name=".fcm.MyFirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
</application>
</manifest>
This issue stems from annotation processing now being included in Gradle from version 2.2. You can fix project and get it running with the following changes.
Project level "build.gradle" remove this line:
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.2'
App level "build.gradle" remove this line:
apply plugin: 'android-apt'
and change this line replacing apt with annotationProcessor:
apt 'net.simonvt.schematic:schematic-compiler:0.6.3'
In build.gradle(Module:app)
remove this two line
1) Top on the file
apply plugin: 'android-apt'
2) in dependencies
apt 'net.simonvt.schematic:schematic-compiler:0.6.3'
add this
annotationProcessor 'net.simonvt.schematic:schematic-compiler:0.6.3'
If the above responses don't work for you, make sure you are using the latest version of Android Studio and gradle plugin (4.4 as of this post) and have changed all the 'compile' lines with 'implementation'.
After that try Build -> Clean Project then Build -> Rebuild Project. (All of this after following #drspaceboo's answer of deleting classpath and plugin lines, then changing apt to annotationProcessor.)
Try this:-
Go to File -> Invalidate Caches / Restart and then Invalidate and Restart.

No resource found that matches the given name (at 'theme' with value '#style/Theme.Intro') when including material-intro in my project

I wanted to add an intro wizard for my app (when you first use it).
I used this library as the source: https://github.com/HeinrichReimer/material-intro
So basically what I did was copying his library folder to my project root location and after building the project I get the following error:
No resource found that matches the given name (at 'theme' with value '#style/Theme.Intro').
More detailed error log:
C:\Users\abhishek rai\AndroidStudioProjects\DonationApp\app\build\intermediates\manifests\full\debug\AndroidManifest.xml
Error:(30, 28) No resource found that matches the given name (at 'theme' with value '#style/Theme.Intro').
Error:Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\abhishek rai\AppData\Local\Android\sdk\build-tools\23.0.2\aapt.exe'' finished with non-zero exit value 1
The code in AndroidManifest.xml is:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="minor.da.com.donationapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="19"
android:targetSdkVersion="23" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme" >
<activity android:name="minor.da.com.donationapp.MainActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="minor.da.com.donationapp.MaterialIntroActivity"
android:parentActivityName="minor.da.com.donationapp.MainActivity"
android:theme="#style/Theme.Intro" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity" />
</activity>
<activity android:name="minor.da.com.donationapp.FinishActivity" >
</activity>
<activity
android:name="minor.da.com.donationapp.Front_page"
android:label="#string/app_name" >
</activity>
<activity android:name="minor.da.com.donationapp.SecondPage" />
<activity
android:name="android.support.v7.widget.TestActivity"
android:label="RecyclerViewTestActivity" />
</application>
</manifest>
Copying the source is not what you would normally do if you use an Android library like material-intro and I'm clearly discouraging you to do so.
You should definitely include it as a Gradle dependency as described in its readme:
Put that in your project's build.gradle:
allprojects {
//...
repositories {
//...
maven {
url 'https://jitpack.io'
}
}
}
And then put that in your module's build.gradle:
dependencies {
//...
compile 'com.heinrichreimersoftware:material-intro:1.2.1'
}
If you yet run into troubles then, please update the question to include your Gradle files.

Categories

Resources