Common Issues and Resolutions in Mobile and Game Development Projects

Cast Mismatch Between LayoutParams Types in ListView Adapters

When inflating item layouts in a ListView adapter, assigning LayoutParams of the wrong parent type causes a ClassCastException. If the parent is a ListView, use AbsListView.LayoutParams instead of LinearLayout.LayoutParams.

View itemView = layoutInflater.inflate(R.layout.item_layout, parent, false);
itemView.setLayoutParams(new AbsListView.LayoutParams(width, height));

Incorrect View Recycling Logic in Adapter's getView

Using exclusive if branches without corresponding else blocks leads to stale view states upon scrolling. When reusing cached views, omitted branches skip UI updates, causing position mismatches.

Use complete conditional coverage:

if (conditionA) {
    textView.setText(valueA);
    textView.setOnClickListener(listenerA);
} else {
    textView.setText(valueB);
    textView.setOnClickListener(null);
}

Manifest Merge Failures During Build

Encountered during import of Eclipse libraries into Android Studio. Removing all content inside <application> in AndroidManifest.xml and refreshing clears the merge conflict. Root cause may involve duplicate or incompatible declarations.

Disconnecting and Reconnecting SVN in Studio Projects

Edit .idea/vcs.xml, replace <mapping directory="" vcs="svn" /> with <mapping directory="" vcs="" />. Delete the hidden .svn folder from project root, then reconfigure SVN linkage via Studio.

IllegalStateException: Closed in OkHttp Response Handling

Calling response.body().string() consumes the stream; subsequent calls fail. Store the result once:

String result = response.body().string();
// Use result; do not call string() again

Exporting AIDL-Based JARs Without Missing Classes

When exporting an Android library containing AIDL interfaces, ensure generated Java files from the gen/ folder are included in the JAR, not just raw sources.

Creating Handlers in Non-Looper Threads

Attempting new Handler() in background threads throws an exception because no Looper exists. Options:

  • Prepare a Looper manually:
Looper.prepare();
Handler handler = new Handler();
Looper.loop();
  • Or reuse main looper:
Handler handler = new Handler(Looper.getMainLooper());

Suppressing Lint Abort on Error

In module build.gradle:

android {
    lintOptions {
        abortOnError false
    }
}

INSTALL_FAILED_NO_MATCHING_ABIS Due to Architecture Mismatch

Build separate ABIs:

android {
    splits {
        abi {
            enable true
            reset()
            include 'x86', 'armeabi-v7a'
            universalApk true
        }
    }
}

Default Interface Methods Require Min API 24

Java 8 default methods require targeting API 24+. Set source/target compatibility:

android {
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

Unity Export Failures on Gradle Initialization

Select Internal (deprecated) build system in Unity's Build Settings to bypass Gradle wrapper issues.

Missing AAPT2 Dependency

Add Google Maven repository in project-level build.gradle:

allprojects {
    repositories {
        google()
        flatDir { dirs 'libs' }
    }
}

Diagnosing compileJava Task Failures

Run gradle compileDebugSource --stacktrace -info in terminal to locate root cause. Follow cascading task failures like processDebugManifest for deeper analysis.

SVN Still Tracking Ignored *.iml Files

Add *.iml pattern in Preferences → Version Control → Ignored Files.

Deprecated SourceSet 'instrumentTest'

Replace with androidTest in module build.gradle:

androidTest.setRoot('tests')

Unknown Failure Installing APKs

Delete app/build directory and rebuild.

R8 Compilation Failures

Causes: conflicting dependencise, duplicate manifest package names, missing Java 8 support. Resolve by removing duplicates, renaming packages, and enabling Java 8:

android {
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

Missing Repositories for Lint and Builder Dependencies

Ensure both google() and jcenter() precede others in buildscript and allprojects blocks.

Groovy-all Not Found During Signed APK Creation

Same as above—add google() before jcenter() in repository list.

libiPhone-lib.a Linker Errors in Xcode

Add linker flags in Build Settnigs:

-Wl -undefined dynamic_lookup

ADB INSTALL_FAILED_INSUFFICIENT_STORAGE

Free device storage or uninstall apps.

Runtime Classpath Resolution Failures

Include library libs path in app build.gradle:

repositories {
    flatDir { dirs '../libraryModule/libs' }
}

Illegal State After onSaveInstanceState

Commit DialogFragment with commitAllowingStateLoss; dismiss using dismissAllowingStateLoss.

Invoke-Customs Require Min API 26

Enable Java 8 as shown earlier.

Command-Line SDK Setup Path Errors

Place cmdline-tools contents under cmdline-tools/latest/bin.

Dynamically Modify gradle.properties in Build Script

project.afterEvaluate {
    def propFile = file("gradle.properties")
    if (propFile.exists()) {
        def props = new Properties()
        props.load(propFile.newDataInputStream())
        props['android.enableAapt2'] = "true"
        propFile.withWriter { props.store(it, null) }
    }
}

CPU Architecture Incompatibility

Specify needed ABIs:

ndk {
    abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86'
}

Malformed URL Exception From Invalid Paths

Avoid spaces or special characters in project paths.

Missing android:attr/offset Resource

Align compileSdkVersion and buildToolsVersion.

GitHub Access Blockage During Git Operations

Use proxy or alternative access methods.

Unity Auto-Requesting Storage Permission

Add to AndroidManifest.xml:

<meta-data android:name="unityplayer.SkipPermissionsDialog" android:value="true" />

Unity Collecting android_id at Launch

Disable analytics package or set submitAnalytics: 0 in ProjectSettings.asset. Alternatively, disable analytics in code at startup.

Permission Revocation Triggers App Restart

Detect non-null savedInstanceState in onCreate() and restart via intent with FLAG_ACTIVITY_CLEAR_TASK.

AAPT2 Linking Crash on Unity Projects

Remove noCompress or list assets explicitly to avoid hitting compression limits.

Assets Excluded from APK by AAPT2 Rules

By default, entries prefixed with _ are ignored. Adjust ignoreAssetsPattern or rename files.

Theme.AppCompat Required Error

Ensure styles inherit from Theme.AppCompat and remove conflicting definitions.

Black Screen After Resuming Game

Call onWindowFocusChanged(true) in UnityPlayerActivity.onStart() for affected Unity versions.

Transform Artifact Failure Due to Jetifier

Disable Jetifier globally or per artifact:

android.enableJetifier=false

Or in gradle.properties:

android.jetifier.ignorelist=aar_name.aar

Tags: Android unity Gradle SVN debugging

Posted on Fri, 22 May 2026 18:11:46 +0000 by GameMusic