Skip to content

Conversation

@kagawagao
Copy link

@kagawagao kagawagao commented Dec 19, 2019

Summary:

Auto detect react-native run-android arguments, ex: MainActivity

  • get MainActivity packageName name by parsing AndroidManifest.xml
  • get all appId by parsing app/build.gradle

related issue: #896

Test Plan:

run react-native run-android custom file structure and multiple flavors

  • custom file structure
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.ziwu">
    <application>
        <!--Page-->
        <activity
            android:name=".module.splash.SplashActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity android:name=".module.main.MainActivity" android:configChanges="keyboardHidden|orientation"/>
    </application>
</manifest>

image

  • custom flavor
android {
    flavorDimensions "app"
    productFlavors {
        xxx {
            applicationId "com.test.xxx"
        }
    }
}
  • run command should work as expect
npx react-native run-android --variant=xxxDebug

custom

  • should work with default config

default

@grabbou
Copy link
Member

grabbou commented Jan 13, 2020

Thanks for sending this PR over! It's a great contribution! However, it's modyfing "config" files which I have been refactoring on a "next" branch.

Let me update the "next" branch to latest "master" and I would merge this PR on that branch instead.

That's where we are cleaning up a lot of runAndroid logic and this PR would be a great addition on top of it.

@grabbou
Copy link
Member

grabbou commented Jan 30, 2020

Looks like this has been automatically resolved after I merged one of the older PRs -> #255 (merged via #934). Apologies for the confusion but that one has been open for more a year and had a priority in being reviewed.

I decided to merge it because it wasn't touching the configuration and was more in line with the way we do things "currently" (I was referring to this in my previous comment).

Now, I want you to know that your work is not going to be just thrown away - this is going to be most likely used on the "next" branch. @thymikee is working on integrating config into run-android (#791) and in that PR, he will need to replace #255 with your work. We will be in touch regarding that in the coming weeks.

Thank you for your contributions and once again, please accept my apologies for not handing the PRs better. I hope that, in the end, it was a great exercise, and that you will submit PRs in the future as well :)

@grabbou grabbou closed this Jan 30, 2020
@kagawagao kagawagao deleted the auto-detect-main-activity branch August 28, 2023 02:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants