How to replace the setupwizard.apk with my own? - android-source

I need to replace the setupwizard with my own to implement some custom initiate, but I don't know how, and is there a way to read the source code of setupwizard.apk?

You will need to define the following intent filter to replace setupwizard.
<intent-filter android:priority="5">
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.DEVICE_INITIALIZATION_WIZARD" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
To view the setupWizard.apk code use the following steps
Get these tools:
1) dex2jar, which is made by a Chinese student. It will translate dex files to jar files
2) jd-gui to view the java files in the jar
The source code is quite readable as dex2jar makes some optimizations.
Procedure:
And here's the procedure on how to decompile:
Step 1:
Convert classes.dex in setupwizard.apk to classes-debug_dex2jar.jar
d2j-dex2jar.sh -f -o output_jar.jar setupwizard.apk
Note: In the Windows machines all the .sh scripts are replaced by .bat scripts

Related

Targeting S+ (version 31 and above) requires that an explicit value for android:exported be defined when intent filters are present]

While debugging the application in android 12, the app is getting crashed.
Android 12 require you to add a piece of code to your main activity
Go to your project folder and open AndroidManifest.xml file
Add the below code in activity
android:exported="true"
Reference:
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:theme="#style/LaunchTheme">
</activity>
In AndroidManifest.xml add android:exported="true":
<manifest ...>
<application ...>
<activity
android:exported="true"
In Android 11 and lower, when declaring an Activity, Service, or Broadcast receiver in AndroidManifest, you did not explicitly declare android:exported. Since the default value is exported=true, you only need to declare exported=false when you do not want to disclose to the outside.
<activity android:name="com.example.app.backgroundService">
<intent-filter>
<action android:name="com.example.app.START_BACKGROUND" />
</intent-filter>
</activity>
Android 12 Changes: Explicit declaration of exported
Apps that set SDK API 31 (android 12) as Target sdk on Android 12 devices must explicitly declare exported in components such as Activity that declared intent-filter. Otherwise, the following error occurs and the installation fails.
Targeting S+ (version 10000 and above) requires that an explicit value for
android:exported be defined when intent filters are present
The application could not be installed: INSTALL_PARSE_FAILED_MANIFEST_MALFORMED
Even for apps targeting SDK API 31, components without intent-filter can omit the exported declaration.
You must explicitly declare exported as follows:
<service android:name="com.example.app.backgroundService"
android:exported="false">
<intent-filter>
<action android:name="com.example.app.START_BACKGROUND" />
</intent-filter>
</service>
Intent-filter is one of the methods for exposing the app's component to the outside. This is because the component of my app can be executed through the resolving of the implicit intent.
On the other hand, there are many cases where it is used for the purpose of executing a component with an implicit intent only inside my app, but it is exposed to the outside because exported is not set, and this may affect the resolving of the implicit intent. .
Thanks #rahul-kavati.
For Xamarin/MAUI it is a property on ActivityAttribute, used like this [Activity(Label = "MsalActivity", Exported = true)]
In Xamarin.Android I faced the same in BroadcastReceiver:
[BroadcastReceiver(Enabled = true, Exported =true)]
[IntentFilter(new[] { BluetoothDevice.ActionFound, BluetoothDevice .ActionUuid, BluetoothDevice .ExtraRssi})]
public class BleReceiver : BroadcastReceiver
and solved with the same Exported=true
The fastest way is to modify the targetSdkVersion in app/build.gradle, the maximum is 30
In AndroidManifest.xml
<activity
android:exported="true"
android:name="com.YOU.APP.activities.MainActivity"
android:launchMode="singleTask"
android:hardwareAccelerated="true">
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
</activity>
If you are using any intent filter or service it must have the android:export property
Currenty if you set minsdk version and get Android Error: Apps targeting Android 12 and higher are required to specify an explicit value for android:exported when the corresponding component has an intent filter defined then I have sollution of that..
Open platforms/android/android.json
Put this line in all plugin you used. android:exported="true" or android:exported="false" (Based on your requirement)
Image Link => https://drive.google.com/file/d/1uAtudZf5iRXUN2tWJvgxsaWeEuZmCUqh/view?usp=sharing
After open platforms\android\app\src\main/AndroidManifest.xml file and delete the plugin activity,meta-data,service,provider..and other things under <application .......>
---Do not delete launcher activity (first activity)--
---delete other data---
Because we changed android.json line. So when we build again than It will auto generate with android:exported..
I spend my whole day in this error. But now I am happy because I got Sollution.

my flutter app icon is not showing on phone apps list

I had created the default(counter) app from flutter and this works perfectly in terms of appearing on the app list as an icon just like any other normal app. However, as i continue adding files to it for example plugins, added firebase too, I rebuild it and the app launches but the app icon does not show on the app list on the phone.
Now am wondering if this is a bug on flutter sdk or what has happened. Since previously I was using flutter version 2.2.2 and now am on flutter 2.5.0
I figured it out I think. The problem is in the android/app/src/main/AndroidManifest.xml. I believe you need to include the following tag in your intent-filters:
<category android:name="android.intent.category.LAUNCHER"/>
However, I had some tags overwriting this one and this is what broke the visibility in the app drawer. My intent filters now look as follows and everything is working now:
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
<!-- <action android:name="android.intent.action.VIEW" /> -->
<category android:name="android.intent.category.DEFAULT" />
<!-- <category android:name="android.intent.category.BROWSABLE" /> -->
<!-- <data android:scheme="my.test.app" /> -->
</intent-filter>
Hope this helps.

Ionic and phonegap barcode scanner app crash on android

My ionic app uses:
"#ionic-native/barcode-scanner": "^5.19.1",
"phonegap-plugin-barcodescanner": "^8.1.0",
Android app crashes right away when i call barcode.scan funcion. I am doing everything like on the very basic example: https://ionicframework.com/docs/native/barcode-scanner
Note: I am testing this on android7 version at the moment. The phone is not very new but still not very old neither.
It crashes right after accepting camera permissions.
There is no err message in catch block or anything, app just crashes.
Has anyone experienced this or can help me investigate more logs ?
I have found the issue, basicly it was missing com.google.zxing.client.android.SCAN from AndroidManifest.xml file:
<activity android:configChanges="orientation|keyboardHidden" android:name="com.google.zxing.client.android.CaptureActivity" android:screenOrientation="landscape" android:theme="#android:style/Theme.NoTitleBar.Fullscreen" android:windowSoftInputMode="stateAlwaysHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="com.google.zxing.client.android.SCAN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
Not sure why the plugin installation did not added anything nor it was described in github, but It was requiring activity for the manifest file.

Eclipse imported but default activity not found

I just imported my eclipse project to android studio, and It studio converted everything fine. But while running the error message shows: Default Activity Not Found.
my manifest file: https://hastebin.com/yigakupoho.xml
You need to define your default activity as android.intent.action.MAIN, like that:
<activity android:name=".YourActivity" android:configChanges="orientation">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>

Android: Installed App icon is not visible in emulator

When I run my application code, I could see the following entry in the console:
[2011-03-01 10:29:26 - mireader] Uploading mireader.apk onto device 'emulator-5554'
[2011-03-01 10:29:26 - mireader] Installing mireader.apk...
[2011-03-01 10:29:40 - mireader] Success!
[2011-03-01 10:29:41 - mireader] Starting activity com.mireader.reader on device emulator-5554
[2011-03-01 10:29:44 - mireader] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.mireader/.reader }
The application's main GUI automatically runs. Until here, there is no problem. When I get back to the application list, there my app icon is not visible. I checked in settings->application->manage application, there I could see my app and it shows uninstall option too.
What is the problem?
probably missing
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
in your main <activity> in the manifest
I had the same problem in Android Studio, with API 19 and with gradle building system. We spent a couple of hours to figure this out, and we realized, if you have more library (for example you have more test app in the same project) and you have more launcher icon in separated library, than gradle cannot solve this. You don't get any error message, just you don't see the icon.
So use different names for launcher icon or just delete which you don't need.
(I just thought, maybe someone gonna have the same problem...)
There was an other scenario as well, when icon is disappear. When you use <data android:scheme="your-own-uri">
The solution is to split intent-filter.
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<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.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="your-own-uri" />
</intent-filter>
</activity>
Just for Android noobs like myself, putting this:
<data android:scheme="file" />
<data android:host="*" />
<data android:pathPattern=".*\\.pdf" />
between the intent filter tags of the main activity also causes an icon disappearing act. The code above is to open a file based on its extension. Remove it and the icon reappears.