When launching MainActivity of Application, it's crashing instantly. When I looked up the adb logs, I was able to find only this,
Exception thrown when launching activities in ProcessRecord
java.lang.IllegalArgumentException: val.length > 91
at SystemProperties.set
When I looked up the source code of android, I found that this could be the root of the problem Android Source Code Of SystemProperties.java. It contains a max value limit of 91.
public static final int PROP_VALUE_MAX = 91;
public static String get(String key) {
if (key.length() > PROP_NAME_MAX) {
throw new IllegalArgumentException("key.length > " + PROP_NAME_MAX);
}
return native_get(key);
}
When I give it a guess, i found that, my application's package name is 108 characters long. And when I changed my app's package name to 60 characters, it worked without any problem.
What could be the issue? This happens only on Asus Zenfone 2 (Lolipop 5.0) model.
There is not problem in any other devices. We are receiving a lot of negative rating due to this problem.
Our app already have 15K downloads in the play store. so changing the app's package name is not an option for me. Please help
Update
To be more precise, there is
no issue in all the android phones we tested other than Asus Zenfone Series
As mentioned by @ViswanathLekshmanan in the comments, I changed the location of MainAcitivity.java file to a lower path.
ie, the original full packagename was :- "com.fourbigbrothers.malayalam_troll_greetings_maker_edit_movie_images_font_seasonal_photo_comments.activities.MainActivity"
I changed it to:- "com.fourbigbrothers.mtm.activities.MainActivity"
Still not working. I've put some logs in onCreate of the MainActivity, but the code execution is not reaching there at all. So I've no idea where to put a try/catch block as mentioned in some answers.
Would there be any solution using the android ndk? And sorry if it'a a dumb question, I'm completely lost.
This is the relevant part of the manifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.fourbigbrothers.malayalam_troll_greetings_maker_edit_movie_images_font_seasonal_photo_comments" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:name="com.fourbigbrothers.boilerplate.base.FbbApplication"
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.FbbApp" >
<activity
android:name="com.fourbigbrothers.malayalam_troll_greetings_maker_edit_movie_images_font_seasonal_photo_comments.activities.MainActivity"
android:label="@string/launcherActivityName"
android:screenOrientation="portrait"
android:launchMode="singleTop"
android:theme="@style/MainActivityTheme" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
</activity>
</application>
Property system is an important feature on android. It runs as a service and manages system configurations and status. All these configurations and status are properties. A property is a key/value pair, both of which are of string type.
From the sense of function, it's very similar to windows registry. Many android applications and libraries directly or indirectly relies on this feature to determine their runtime behavior. For example, adbd process queries property service to check if it's running in emulator. Another example is the java.io.File.pathSeparator
returns the value stored in property service.
The high level architecture of property system is shown as following.
I strongly recommend to you over walk the proposed answer. Why?
Look at the property_service.h. This is a class that will called whe you execute SystemProperties.set
method in native. If you trying to set native_set(key,val) you will not get a positive result due to is_legal_property_name method, that check property rules on the native level.
When I give it a guess, i found that, my application's package name is 108 characters long. And when I changed my app's package name to 60 characters, it worked without any problem.
Just a guess. Look to SystemProperties
like an analogue of SharedPreference in Android. You don't need a set full path to your Activity as key
. Just put a Name. Or with prefex or something like this.
After several searches I found a source of Native SystemProperties file. He also defines 92
as max length of value, and 32
as a max length of key. So this is a restriction on the Linux low level.
You can fix this only by cut your key
value (<package_name>
.MainActivity in your case)
http://rxwen.blogspot.com/2010/01/android-property-system.html
A third-party application does not have permission to set a system property. Therefore, the most likely cause of the crash is that the system is setting the package-name as a value for a system property.
Other answers are correct in that the max value of a system property is 92 characters and the max key is 32 characters. However, your app is not setting the system property.
There isn't much you can do to resolve this issue on your end. I would open an issue with Asus and consider changing your package-name (perhaps only for the Asus Zenfone 2). Unfortunately, as you are already aware, you would need to publish a new app if you changed the package-name. Hopefully Asus pushes an update that fixes this issue. Also, a good reason to consider the length of a package-name before releasing to production :)
Tricky problem...next time shorter package names :)
Did you try to change only the package of activities.MainActivity?
like:
com.fourbigbrothers.malayalam_troll_greetings_maker_edit_movie_images_font_seasonal_photo_comments.a.MA
If that solves the problem you could create a tool (in gradle, java, python or whatver) to rename all classes/packages of your project using Base64 to use the minimum number of characters possible before building the project.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With