Different package names to be added in desired capabilities in appium - java

We have an android app which is composed of two different apps.
Launcher activity is present in 1 project which has a package name
in.foo.android.main.MainActivity
while app package which is shown in uiautomator view is something like
com.abc.android.debug
in desired capabilites I am setting following :
capabilities.setCapability(MobileCapabilityType.APP_PACKAGE ,"com.abc.android.debug");
capabilities.setCapability(MobileCapabilityType.APP_ACTIVITY,"in.foo.android.main.MainActivity");
So getting below error
com.abc.android.debug/in.foo.android.main.MainActivity is not a launchable activity
Here appium is adding package name by default before the main activity.
can someone provide some help here.

First
Go to CMD as admin type adb devices
Make sure that your device already opened the apps that you want
go to cmd and type adb shell dumpsys window | find "mCurrentFocus"
this the exp
Thats command will showing the current activity
Second
Install the APK Info from playstore (idk if you try on the appstore)
https://play.google.com/store/apps/details?id=com.wt.apkinfo&hl=in&gl=US
Open the APK Info
Search your apps s name and click it
You will see this screen
appdetail
Scroll down and check the activities
activities
You will see all of the activity on the apps
existingactivity

Related

How to add image to emulator's gallery in HarmonyOS?

I am testing a HarmonyOS application and want to add an image to the emulator's gallery.
In Android Studio, we can send any file into the android emulator via drag-n-drop action,
but drag-n-drop isn't working here.
What is the alternative for this in HarmonyOS?
Welcome to the community!
You can transfer files in HarmonyOS Simulators from your computer via the following command, images will appear in Gallery once pushed -
Steps:
Make sure the device (Simulator / Phone) is running.
Run DevEcoStudio -> Open Terminal.
Make sure the Device is connected to DevEcoStudio.
Make sure you have HMOS_Home set in environment variables in your computer.
Run hdc file send command with arguments. The terminal will show messages with success or failure after execution.
hdc file send [LOCAL file path of computer] [REMOTE location in device]
Example -
Currently, drag-and-drop is not supported. You can run the following HDC command to transfer files:
hdc file send D:/a.jpg /sdcard

DebugView no devices available

I'm doing some tests on a small app to understand how firebase-analytics works. This is the code for the MainActivity:
public class MainActivity extends AppCompatActivity {
private FirebaseAnalytics mFirebaseAnalytics;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mFirebaseAnalytics = FirebaseAnalytics.getInstance(getApplicationContext());
mFirebaseAnalytics.setAnalyticsCollectionEnabled(true);
mFirebaseAnalytics.setMinimumSessionDuration(10000);
mFirebaseAnalytics.setSessionTimeoutDuration(300);
Bundle bundle = new Bundle();
bundle.putString(FirebaseAnalytics.Param.ITEM_ID,"ID");
bundle.putString(FirebaseAnalytics.Param.ITEM_NAME,"NAME");
bundle.putString(FirebaseAnalytics.Param.CONTENT_TYPE,"image");
mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.SELECT_CONTENT, bundle);
}
To see if my app send data to Firebase I tryed to use DebugView but it says that there isn't any devices available, i also used the command
adb shell setprop debug.firebase.analytics.app <package_name>
but nothing changed.
If i use these 3 commands
adb shell setprop log.tag.FA VERBOSE
adb shell setprop log.tag.FA-SVC VERBOSE
adb logcat -v time -s FA FA-SVC
i can see that my app is sending some data to firebase, like in this picture
What can i do to enable DebugView and see what my app send to firebase in real time?
Please ensure that the following steps have been followed:
Step 1: Your app is properly configured in the Firebase console to support the Analytics features.
Step 2:
A) If you are simply working with single build variant, the following command is enough:
adb shell setprop debug.firebase.analytics.app [your_app_package_name]
B) But if you are working with multiple build variants with different application IDs which are not the same as the app package name, be sure to execute the following command:
adb shell setprop debug.firebase.analytics.app [your_application_id]
Here, application ID is the app ID of your build variant found in the corresponding gradle file. For example, lets say you have x.gradle and y.gradle for two build variants x and y, and you also have the general build.gradle file. To debug the build variant x with application ID com.abc.x, the command will be:
adb shell setprop debug.firebase.analytics.app com.abc.x
Similarly, to debug the build variant y with application ID com.abc.y, the command will be:
adb shell setprop debug.firebase.analytics.app com.abc.y
This behavior persists until you explicitly disable it by executing the following command:
adb shell setprop debug.firebase.analytics.app .none.
I had the same symptoms as you did. In my case the problem was simply because I forgot to turn on WiFi, so events couldn't be propagated to cloud but were appearing in logcat.
I've spent insane amount of time debugging this, and my conclusion - it is the Firebase instability, because I get events intermittently, and there is no pattern to what makes them appear in that DebugView
You can see your list of devices -> adb devices
and then -> adb shell setprop debug.firebase.analytics.app package_name
after that, in Android Studio, run by Debug
Ok for me.... the reason was because I was having this on my second screen =>
Lessons learnt:
Android Emulators messes up with the ADB and have an impact on firebase debug view.
Don't play games during work... It's 'DIRECTLY' counter productive.
This command will be helpful to see debug view in firebase analytics:
adb shell setprop debug.firebase.analytics.app
One additional note specified in firebase Google support
Note: Before using DebugView, you should ensure that your device time is accurate. A skewed device clock will result in delayed or missing events in your Analytics reports.
You can refere to below link :
https://support.google.com/firebase/answer/7201382?hl=en
My situation may not be relevant but posting for my future sanity if nothing else.
I had created a new project in firebase and also was having the problem where it said the 'Finish the sdk setup' error trying to communicate with my application (which I had just finished renaming the android package-prompting to create a new project in Firebase)
I was trying to get debugging to work to 'kick' it into connecting, but was getting not devices so I knew there was something wrong.
My issue was my google-services.json filed. It had a reference to my old project name in there AS WELL as my new one. So maybe it was getting confused?
Under client, there were two objects with client_info, api_key, etc. I removed the old one, leaving only the newer correct one.
"client": [
{...}, // <-- removed this one
{...}
]
Make sure you haven't disabled Firebase Analytics logging either on Gradle or on your manifest.

Android - Remove permission programmatically

in the last days I try to make a simple Android app that can run adb command , more specific this command pm revoke com.example.app android.permission.ACCESS_NETWORK_STATE.
I try to run this from pc and say me that I can't because this permission isn't changeable.
With root is possible? or there are other method to block the internet connection to one app?

Eclipse - Android - Cannot debug

I don't have any problems with running my application, but when I want to debug it's not starting Acticity and I'm not in debug mode.
Uploading TatryAR.apk onto device 'emulator-5554'
Installing TatryAR.apk...
Success!
Starting activity com.TatryAR.main.MainActivity on device emulator-5554
and that's all - nothing starts.
I can click apk and it works, but not in debug mode.
I've cleaned projects - Project > Clean
I've change debug configuration - Launching default activity to particular activity, always prompt to pick devices and automatically pick.
I've clicked and unclicked Skip breakpoint
Also restarted Eclipse and Windows also
You can attach the debugger to an existing process in Eclipse by choosing the process from the device window and clicking on the attach debugger button.
See this post for further details:
How to attach back the Android emulator to ADB?

Trouble reading an XML file in Android

I'm trying to parse an XML file thru a DOM parser. However, I am having difficulty in getting my Main Activity to actually read the file. I've read that I should place the file in Assets and then called with getAssets(). I used something like this:
InputStream is = this.getAssets().open("myXML.xml");
This just results in an error: Unexpected error while launching logcat. Try reselecting the device.] device not found.
I've also tried new File("myXML.xml") using variations on the absolute path. Nothing seems to work. I'm getting a little frustrated. Does anyone have any suggestions?
sounds to me, as if your IDE has no connection to the Emulator or device on which you are trying to test your app.
LogCat is a logging output stream that can be used by any app to print out informations /logs. And LogCat needs to be connected (via ADB) to your device.
If you don't have a real phone connected you can use an emulator:
/path/to/your/androidSDK/tools/android
this SDK manager helps you to create a new AVD (Android Virtual Device). Klick Tools>
Manage ACDs> New...
If you have a real phone or tablet connected to your computer, try restarting ADB
(should be possible from within your IDE) or use the command line.
change to the directory where the Android SDK is installed (in windows something like):
c:\Program Files\Android\android-sdk-windows\platform-tools\
on linux it could be:
/opt/android-sdk-linux/platform-tools/
then type (win and linux)
adb kill-server
adb start-server

Categories