# Error in android Building

**URL:** <https://forum.ionicframework.com/t/error-in-android-building/243293>\
**Category:** Capacitor\
**Created:** [July 25, 2024, 4:50pm UTC](https://forum.ionicframework.com/t/error-in-android-building/243293 "2024-07-25T16:50:44Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![eliwakeling](https://avatars.discourse-cdn.com/v4/letter/e/cc9497/32.png) [@eliwakeling](https://forum.ionicframework.com/u/eliwakeling)\
**Post date:** [July 25, 2024, 4:50pm UTC](https://forum.ionicframework.com/t/error-in-android-building/243293/1 "2024-07-25T16:50:44Z")

</div>

After updating capacitor, I find this error with my company’s app’s firebase dependancy: FirebaseInstallations.getInstance().getToken(false).addOnSuccessListener(getActivity(), instanceIdResult → {  
^  
class file for androidx.appcompat.app.AppCompatActivity not found

I tried updating some of the dependancies, but I was not able to figure out what could be wrong here.

---

<div class="post-metadata">

**Author:** ![twestrick](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/twestrick/32/136131_2.png) [@twestrick](https://forum.ionicframework.com/u/twestrick)\
**Post date:** [July 26, 2024, 7:39pm UTC](https://forum.ionicframework.com/t/error-in-android-building/243293/2 "2024-07-26T19:39:32Z")

</div>

Try going through these troubleshooting steps - [Troubleshooting Android Issues | Capacitor Documentation](https://capacitorjs.com/docs/android/troubleshooting)

---

<div class="post-metadata">

**Author:** ![eliwakeling](https://avatars.discourse-cdn.com/v4/letter/e/cc9497/32.png) [@eliwakeling](https://forum.ionicframework.com/u/eliwakeling)\
**Post date:** [July 30, 2024, 5:30pm UTC](https://forum.ionicframework.com/t/error-in-android-building/243293/3 "2024-07-30T17:30:53Z")

</div>

Hey, thanks, it told me to update my Android Gradle Plugin, which I did, but now I’m having an issue in the namespace. I’m new to the forums, would it be better for me to post a new topic? I’m currently looking through other posts so that I can better understand how this place works.

---

<div class="post-metadata">

**Author:** ![twestrick](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/twestrick/32/136131_2.png) [@twestrick](https://forum.ionicframework.com/u/twestrick)\
**Post date:** [July 30, 2024, 6:01pm UTC](https://forum.ionicframework.com/t/error-in-android-building/243293/4 "2024-07-30T18:01:02Z")

</div>

This thread is fine since it is a continuation of your issue 🙂

What version of Capacitor are you running? If the latest v6, I would stick with Gradle 8.2.1.

What is the exact error you are getting?

---

<div class="post-metadata">

**Author:** ![eliwakeling](https://avatars.discourse-cdn.com/v4/letter/e/cc9497/32.png) [@eliwakeling](https://forum.ionicframework.com/u/eliwakeling)\
**Post date:** [July 30, 2024, 6:27pm UTC](https://forum.ionicframework.com/t/error-in-android-building/243293/5 "2024-07-30T18:27:41Z")

</div>

```auto
Namespace not specified. Specify a namespace in the module's build file: /Users/User/DevelopmentApp/mobile_app/node_modules/@capacitor/app/android/build.gradle. See https://d.android.com/r/tools/upgrade-assistant/set-namespace for information about setting the namespace.

If you've specified the package attribute in the source AndroidManifest.xml, you can use the AGP Upgrade Assistant to migrate to the namespace value in the build file. Refer to https://d.android.com/r/tools/upgrade-assistant/agp-upgrade-assistant for general information about using the AGP Upgrade Assistant.

```

This is the error I’m recieving at the moment. My build.gradle is formatted like this:

```auto
android {
    namespace "namespace.program.app"
    compileSdkVersion rootProject.ext.compileSdkVersion
    defaultConfig {
        applicationId "namespace.program.app"
        namespace "namespace.program.app"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 16
        versionName "1.0.6"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        aaptOptions {
             // Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
             // Default: https://android.googlesource.com/platform/frameworks/base/+/282e181b58cf72b6ca770dc7ca5f91f135444502/tools/aapt/AaptAssets.cpp#61
            ignoreAssetsPattern '!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~'
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

```

I am using latest version Capacitor so I could take advantage of the splash screen capabilities, AGP upgraded me to the latest gradle version and I don’t know how to downgrade if that is the problem.

---

<div class="post-metadata">

**Author:** ![twestrick](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/twestrick/32/136131_2.png) [@twestrick](https://forum.ionicframework.com/u/twestrick)\
**Post date:** [July 30, 2024, 6:44pm UTC](https://forum.ionicframework.com/t/error-in-android-building/243293/6 "2024-07-30T18:44:15Z")

</div>

I don’t believe there should be `namespace "namespace.program.app"` under `defaultConfig`.

---

<div class="post-metadata">

**Author:** ![eliwakeling](https://avatars.discourse-cdn.com/v4/letter/e/cc9497/32.png) [@eliwakeling](https://forum.ionicframework.com/u/eliwakeling)\
**Post date:** [July 30, 2024, 6:49pm UTC](https://forum.ionicframework.com/t/error-in-android-building/243293/7 "2024-07-30T18:49:10Z")

</div>

I saw it in one of the fixes I was looking before I turned up here. Doesn’t seem like changing that worked unfortunately.

---

<div class="post-metadata">

**Author:** ![julio-ionic](https://avatars.discourse-cdn.com/v4/letter/j/58956e/32.png) [@julio-ionic](https://forum.ionicframework.com/u/julio-ionic)\
**Post date:** [July 31, 2024, 12:00pm UTC](https://forum.ionicframework.com/t/error-in-android-building/243293/8 "2024-07-31T12:00:58Z")

</div>

The error is pointing to `@capacitor/app` package, not to your app, did you update the `@capacitor` plugins you use?

---

<div class="post-metadata">

**Author:** ![eliwakeling](https://avatars.discourse-cdn.com/v4/letter/e/cc9497/32.png) [@eliwakeling](https://forum.ionicframework.com/u/eliwakeling)\
**Post date:** [July 31, 2024, 5:20pm UTC](https://forum.ionicframework.com/t/error-in-android-building/243293/9 "2024-07-31T17:20:59Z")

</div>

Allright, I filled out the namespace in the files where it directed me. However, at android/capacitor-cordova-android-plugins/build.gradle, whenever I try to npx sync it, the namespace is removed, creating an error when I try to build it.

---

<div class="post-metadata">

**Author:** ![julio-ionic](https://avatars.discourse-cdn.com/v4/letter/j/58956e/32.png) [@julio-ionic](https://forum.ionicframework.com/u/julio-ionic)\
**Post date:** [July 31, 2024, 5:39pm UTC](https://forum.ionicframework.com/t/error-in-android-building/243293/10 "2024-07-31T17:39:12Z")

</div>

You have to update to at least Capacitor 5 (while 6 is recommended) and all the other `@capacitor` packages should match the major version.  
Then you won’t run into those problems and won’t need to manually change anything.

---

<div class="post-metadata">

**Author:** ![eliwakeling](https://avatars.discourse-cdn.com/v4/letter/e/cc9497/32.png) [@eliwakeling](https://forum.ionicframework.com/u/eliwakeling)\
**Post date:** [August 2, 2024, 5:19pm UTC](https://forum.ionicframework.com/t/error-in-android-building/243293/11 "2024-08-02T17:19:33Z")

</div>

Turns out that I didn’t migrate when I should have so the errors regarding namespace not being specified is no longer there, the original error is back unfortunately regarding firebase.

```auto
error: cannot access AppCompatActivity
        FirebaseInstallations.getInstance().getToken(false).addOnSuccessListener(getActivity(), instanceIdResult -> {

                                                                                            ^
  class file for androidx.appcompat.app.AppCompatActivity not found

```

Firebase is implemented like this:

```auto
public void getToken(final PluginCall call) {
        FirebaseInstallations.getInstance().getToken(false).addOnSuccessListener(getActivity(), instanceIdResult -> {
            JSObject data = new JSObject();
            data.put("token", instanceIdResult.getToken());
            call.resolve(data);
        });
        FirebaseInstallations.getInstance().getId().addOnFailureListener(e -> call.reject("Failed to get instance FirebaseID", e));
    }

```

---

<div class="post-metadata">

**Author:** ![julio-ionic](https://avatars.discourse-cdn.com/v4/letter/j/58956e/32.png) [@julio-ionic](https://forum.ionicframework.com/u/julio-ionic)\
**Post date:** [August 5, 2024, 2:32pm UTC](https://forum.ionicframework.com/t/error-in-android-building/243293/12 "2024-08-05T14:32:14Z")

</div>

In which Capacitor version were you before updating?  
You have to update from version to the next major version following each version upgrade guide.

Or you can go directly to latest version but removing ios/android folders and adding them again with `npx cap add` so the projects have all the required changes (you will lose any manual changes you’ve made to the native projects)

---

<div class="post-metadata">

**Author:** ![eliwakeling](https://avatars.discourse-cdn.com/v4/letter/e/cc9497/32.png) [@eliwakeling](https://forum.ionicframework.com/u/eliwakeling)\
**Post date:** [August 5, 2024, 4:05pm UTC](https://forum.ionicframework.com/t/error-in-android-building/243293/13 "2024-08-05T16:05:55Z")

</div>

> [@julio-ionic](#):
>
> removing ios/android folders and adding them again with `npx cap add` so the projects have all the required c

I was at version 3, but I moved to version six, I made sure to update what was needed to be updated when I upgraded the versions, I’ll double check, but I do believe I followed the version guides.
