Showing posts with label Android. Show all posts
Showing posts with label Android. Show all posts

9/17/2018

SOLVED React Native android build error GC overhead limit exceeded

Problem

Today I recently encountered an error while building four react native android applications, the error was:

* What went wrong:
Execution failed for task ':app:mergeReleaseResources'.
> GC overhead limit exceeded
and
* What went wrong:
Execution failed for task ':app:transformClassesWithMultidexlistForRelease'.
> GC overhead limit exceeded

Solution

It appears it has something to do with the memory of the machine or pc, all I did was restart my pc to clear all the previous processes and clean up the memory usage and then build the app again.

I also noticed that while I was developing for 5 hours, my machine was slowly slowing  down which gave me the hint to restart my pc. Anyways, restarting your machine or pc should fix this issue 95% of the time. Hope this helps.

9/13/2018

SOLVED ReactNative WebRTC update issue | Android O (--min-api 26)

Problem

I recently upgraded my ReactNative WebRTC version from "1.58.3" to "1.67.1" which causes my app to fail when building or even running it. The exact error I encountered is:

D8: Invoke-customs are only supported starting with Android O (--min-api 26)
D8: Static interface methods are only supported starting with Android N (--min-api 24): org.webrtc.EglBase org.webrtc.EglBase.create()

Solution

1. In your project root directory go to "android/app/" and open the file build.gradle

2. Copy and paste the code below within the android config.

compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
}

Example:

Build you react native app again and it should work.

9/06/2018

Get string values from Android strings.xml in React Native

Problem

I am working on a mobile app project that contains multiple app builds in React Native. Whenever I build a specific app, the string called "app_name" inside my

/android/app/src/main/res/values/strings.xml 

keeps on changing. I intended to do this so that the native part of my code knows what app I was building.

My goal here is to get the value of the string "app_name" so that can be able to render a specific asset(s) or use a specific java function intended for that app.

Solution

I have my strings.xml looks like this:


All I did was create a String function and inside that function I use getResources() and getString() to get the string value of app_name inside strings.xml;

Here is the code:


Using this approach, I am now able to pass the values inside strings.xml to my react native app. I was able to compare the value of the function appName() using appName().equals("appone") that return either true if match or false if not match.

Hope it helps.

8/03/2018

Error running 'app': Default Activity not found on Android with Kotlin

Problem:


I started learning Android and decided to use Kotlin instead of Java so I setup my first project and added MainActivity.kt and started running it in debug mode. I was so excited to run my first native app and see the output but this error killed my excitement.

Error running 'app': Default Activity not found on Android with Kotlin

It felt like I am in between two planets colliding when seeing this error so I took time to do some research and got a solution.

Solution:


Inside AndroidManifest.xml you have to add the code below within activity tag.

It should look like this:


I ran the code again and it worked perfectly.