hnvn / flutter_image_cropper

A Flutter plugin for Android and iOS supports cropping images
1k stars 393 forks source link

Android Manifest Error - “com.yalantis.ucrop.UCropActivity, was not found in the project or the libraries” #206

Open Jswiizle opened 4 years ago

Jswiizle commented 4 years ago

I am getting the error "Class referenced in the manifest, com.yalantis.ucrop.UCropActivity, was not found in the project or the libraries " when I add an activity to my Android Manifest file. Here is the code which is causing the error:

<activity android:name="com.yalantis.ucrop.UCropActivity" android:screenOrientation="portrait" android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>

I am trying to install the image_cropper package, and in the installation guide it requires that I add this activity statement to the Android Manifest file. I am using MacOS

What I have tried:

1) I have followed the note in the installation guide "From v1.2.0, you need to migrate your android project to v2 embedding (detail)"

2) I ran pub get when I added to my pubspec.yaml

3) I ran flutter doctor and received the following warning: "Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses" - I ran the command in my terminal and the output was: " flutter: command not found"

4) Cleaned my flutter project and restarted Android Studio

luccafreitas commented 4 years ago

Same issue. Anyone knows a fix?

VimfanTPdvorak commented 4 years ago

I solved that problem by manually editing the AndroidManifest.xml file, adding this activity tag inside the application tag:

<activity
            android:name="com.yalantis.ucrop.UCropActivity"
            android:screenOrientation="portrait"
            android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>

Note that I have tried to change the android:name="com.yalantis.ucrop.UCropActivity" to android:name=".UcropActivity" and it just won't work. So, currently that's the only way I've found that can solve that problem.

luccafreitas commented 4 years ago

Yeah, I have done that and it looks like @Jswiizle did the same, by adding the activity inside application tag (before < / application >) and the problem continues. I'm not sure what the problem actually is with the manifest file.

VimfanTPdvorak commented 4 years ago

Ops. Yeah. I didn't carefully read @Jswiizle message. He/she did mention that. My problem was solved only by adding that, though. So I guess I was just really lucky. Anyway, I'm currently using Android Studio version 4.0.1 and Flutter version 1.20.4. Here is my complete AndroidManifest.xml file:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.novellpharm.my_novell_app">
    <!-- io.flutter.app.FlutterApplication is an android.app.Application that
         calls FlutterMain.startInitialization(this); in its onCreate method.
         In most cases you can leave this as-is, but you if you want to provide
         additional functionality it is fine to subclass or reimplement
         FlutterApplication and put your custom class here. -->
    <uses-permission android:name="android.permission.INTERNET" />
    <application
        android:name=".Application"
        android:label="My Life"
        android:icon="@mipmap/ic_launcher">
        <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">
            <!-- Specifies an Android theme to apply to this Activity as soon as
                 the Android process has started. This theme is visible to the user
                 while the Flutter UI initializes. After that, this theme continues
                 to determine the Window background behind the Flutter UI. -->
            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />
            <!-- Displays an Android View that continues showing the launch screen
                 Drawable until Flutter paints its first frame, then this splash
                 screen fades out. A splash screen is useful to avoid any visual
                 gap between the end of Android's launch screen and the painting of
                 Flutter's first frame. -->
            <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"/>
                <action android:name="FLUTTER_NOTIFICATION_CLICK" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

        <activity
            android:name="com.yalantis.ucrop.UCropActivity"
            android:screenOrientation="portrait"
            android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>

        <!-- 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" />
    </application>
</manifest>
luccafreitas commented 4 years ago

I realized I made the silliest mistake, I merged an old project into a new one, and my AndroidManifest.xml was in the wrong place xD @Jswiizle Make sure it's in android/app/src/main hope that's your case as well.

ruguk commented 3 years ago

Maybe you need flutter upgrade

DennisKragekjaer commented 3 years ago

Im having same issue, it works in debug, but in release its not working. Did everything people are suggesting here, no luck. Are there any here who can help solving this?

145841763_10158825054001063_7024460098567144667_n

DennisKragekjaer commented 3 years ago

Solved not working in release mode on Android. Actually event if manifest file looks like the photo, its not the problem. The problem was ImagePicker package, and is solved by

in android/build.gradle make sure that version of tools is 3.5.4 not 4.1.1 or higher dependencies { classpath 'com.android.tools.build:gradle:3.5.4' // ... } That solved my issue.