I am hooking an app now i m founding this error i have already tried many solutions one of which is following:
Java.perform(function() {
var main;
Java.choose('ca.c.edu.char.g', {
onMatch: function(instance) {
main = instance;
},
onComplete: function() {console.log(main.Key);}
});
});
Here Key is a method i found after decompiling it with jadx-gui but it is not working ..Any help??
in the function Java.choose char is package and its class is g
Related
I'm trying to create a custom Debug Tree class to get the same result as the following:
I have followed this Stackoverflow answer:
Log method name and line number in Timber
But using that answer gives me two problems:
Implementing the custom Debug Tree class does not log anything when I use more than one method.
public class MyDebugTree extends Timber.DebugTree {
#Override
protected String createStackElementTag(StackTraceElement element) {
return String.format("(%s:%s)#%s",
element.getFileName(),
element.getLineNumber(),
element.getMethodName());
}
}
public class BaseApplication extends Application {
#Override
public void onCreate() {
super.onCreate();
if (BuildConfig.DEBUG) {
Timber.plant(new MyDebugTree);
}
}
}
The above causes it to not log at all.
If I use only return element.getFileName(); it successfully logs that one error.
The second problem I'm having is that using a custom DebugTree class does not give me the same results as using err.getStackTrace()[0].getLineNumber().
}, err -> {
Timber.e("Method name: " + err);
Timber.e("Method name: " + err.getStackTrace()[0].getMethodName());
}
The custom Debug Tree class does not display the name of the method I'm trying to log.
Why is it not logging when I use all three methods?
Also how can I get it to log like it would using
err.getStackTrace()[0].getMethodName()?
I'm using 'com.jakewharton.timber:timber:4.7.1'
You seem to be doing it right. I recreated your code in kotlin (programming language should not matter) and i was able to show my logs.
MyDebugTree.kt
class QueenlyDebugTree : Timber.DebugTree() {
override fun createStackElementTag(element: StackTraceElement): String {
return "(${element.fileName}:${element.lineNumber})#${element.methodName}"
}
}
force log using an actual exception:
try {
throw RuntimeException("Hello World")
} catch (e: Exception) {
Timber.e(e)
}
i got a log:
So, from what i saw from your code, its most probably because you have a compact logcat view. To update your logcat view, follow these steps:
1. Make sure you have standard view selected
2. Configure standard view
3. Make sure Show tags is selected and tag column is at max(35)
I am trying to build a Home Launcher App in Xamarin
Currently I have a Xamarin Forms App with Access to Xamarin Android through interfaces. In Xamarin Android I have a method to find all package Names on the device like this:
[assembly: Xamarin.Forms.Dependency(typeof(Launcher.Droid.GetLauncher))]
namespace Launcher.Droid
{
class GetLauncher : MainActivity,IGetLauncher
{
public string GetPackageName(int index)
{
var apps = Android.App.Application.Context.PackageManager
.GetInstalledApplications(PackageInfoFlags.MatchAll);
return apps[index].PackageName; ;
}
}
}
I can access this function from Xamarin Forms to get the package names.
Now I want to launch an App with a certain package Name:
I have tried the following code also in Xamarin Android accessed by an Interface from Xamarin Forms:
[assembly: Xamarin.Forms.Dependency(typeof(Launcher.Droid.GetLauncher))]
namespace Launcher.Droid
{
class GetLauncher : MainActivity,IGetLauncher
{
public void RunApp(int index)
{
var apps = Android.App.Application.Context
.PackageManager.GetInstalledApplications(PackageInfoFlags.MatchAll);
Intent intent =
PackageManager.GetLaunchIntentForPackage(apps[index].PackageName);
StartActivity(intent);
}
}
}
which results in the following error:
Java.Lang.NullPointerException
Nachricht = Attempt to invoke virtual method 'android.content.pm.PackageManager android.content.Context.getPackageManager()' on a null object reference
The Error occurs on the PackageManager.GetLaunchIntentForPackage Line.
I am testing on a physical device.
Any Help or hints would be highly appreciated.
Try to change your codes like below:
[assembly: Xamarin.Forms.Dependency(typeof(Launcher.Droid.GetLauncher))]
namespace Launcher.Droid
{
class GetLauncher : IGetLauncher
{
public void RunApp(int index)
{
var apps = Android.App.Application.Context.PackageManager.GetInstalledApplications(PackageInfoFlags.MatchAll);
Intent intent = Android.App.Application.Context.PackageManager.GetLaunchIntentForPackage(apps[index].PackageName);
Android.App.Application.Context.StartActivity(intent);
}
}
}
I am developing an APP with wechat login feature. After getting approval from wechat it will call a custom activity of my NativeScript APP. I am getting response correctly but how can I move to another page instated of the home page after doing some verification. I am using NativeScript + Angular.
Sample code
getJSON("https://api.weixin.qq.com/sns/oauth2/access_token?appid=ID&secret=SECRET&code=" + res.code + "&grant_type=authorization_code").then((res) => {
console.dir(res);
// ===> here I want navigation
}, err => {
console.dir(err);
})
I tried like this:
frame.topmost().navigate("src/app/login/login.component");
but getting error:
JS: Unhandled Promise rejection: Cannot set property '_moduleName' of undefined ; Zone: ; Task: Promise.then ; Value: TypeError: Cannot set property '_moduleName' of undefined TypeError: Cannot set property '_moduleName' of undefined
Please give me some suggestions. Thanks in advance :)
Fire an event from the Activity callback, something like
import { android } from "tns-core-modules/application";
...
public onResp(res: com.tencent.mm.opensdk.modelbase.BaseResp) {
console.log("onResp");
console.dir(res);
androidApp.notify(<AndroidActivityEventData>{ eventName: 'wxapiresponse', object: android, activity: this });
}
In app component, listen to the event
export class AppComponent implements OnInit {
constructor(private ngZone: NgZone, private routerExtensions: RouterExtensions) {}
ngOnInit() {
application.android.on('wxapiresponse', this.wxApiResponse, this);
}
wxApiResponse() {
// making sure the event callback runs inside Angular zone
this.ngZone.run(() => {
this.routerExtensions.navigate(...);
});
}
}
A similar problem cost me an entire Weekend, without knowing how the companion controller .js or .ts files look like I can only recommend you go to the basics / source:
https://docs.nativescript.org/core-concepts/navigation#frame
it helped me find the problem in my code.
If you wrote a custom Page that does not start from a template chances are you wrote the controller too and it's easy to overlook some line that is present in the samples - even thou it looks like you don't need it.
If you paste your controller JS we could understand your context.
For instance, here is piece of code you should definitely include to help you debug:
in your page-you-navigate-to.xml
<Page loaded="onPageLoaded" class="page">
...
</Page>
in your page-you-navigate-to.ts
import { EventData } from "tns-core-modules/data/observable";
import { Page } from "tns-core-modules/ui/page";
export function onPageLoaded(args: EventData): void {
const page = <Page>args.object;
var context = page.navigationContext;
page.bindingContext = context;
console.log("Target page Loaded.");
}
Start your debugger, and step through see where you have null values and read up on those method calls and their parameters.
We are using Carto Xamarin Mobile SDK to develop app with offline maps support. It works fine until user does not try to resume application after it has been disposed. Activity creation (activity uses carto package manager) crashes with exception:
Carto.PackageManager.CartoPackageManager.CartoPackageManager(string source, string dataFolder)<01980a2dae7148abb92e6b982667f448>:0
App.Droid.OfflineMaps.AndroidMapPackageManager.AndroidMapPackageManager()<76ae23b9271c407d865ebb6162639870>:0
App.Droid.Plugins.MapDownloader.Plugin.<>c.<Load>b__0_0()<76ae23b9271c407d865ebb6162639870>:0
MvvmCross.Platform.IoC.MvxSimpleIoCContainer.<>c__DisplayClass33_0<TInterface>.<RegisterSingleton>b__0()<4ddde23419c5494288c799fcdbb0f189>:0
MvvmCross.Platform.IoC.MvxSimpleIoCContainer.ConstructingSingletonResolver.Resolve()<4ddde23419c5494288c799fcdbb0f189>:0
MvvmCross.Platform.IoC.MvxSimpleIoCContainer.InternalTryResolve(Type type, MvxSimpleIoCContainer.IResolver resolver, ref object resolved
App.Core.ViewModels.Blocks.Maps.Offline.MapDownloaderOwnerViewModel.EnableMapDownloader(City city)<d6cca792b401420d922bc024
Here on line 105 you can see where exception is originally thrown.
In the regular entering page it works fine.
PackageManager request is happening in the ctor of the page ViewModel via:
Mvx.Resolve<MapDownloadsManager>(); // It receivs as injection platform-dependent packageManager
It seems that the problem is in the database path.
We are generating the folder name that then passed to the CartoPackageManager constructor in the following way:
private static string CreateFolder(string folderPath)
{
var folder = GetDocumentDirectory(folderPath);
if (!Directory.Exists(folder))
{
Directory.CreateDirectory(folder);
}
return folder;
}
private static string GetDocumentDirectory(string withFolder = null)
{
var documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
return withFolder == null ? documents : Path.Combine(documents, withFolder + "/");
}
Do you have any ideas where the source of the problem could be?
P.S.: Carto SDK v 4.0.2, MvvmCross 4.4.0, unfortunately can't update to the newer now.
After some research I have spotted that task queue is reset, now supposing that app actually crashes here in source code:
std::string taskDbFileName = "tasks_v1.sqlite";
try {
_taskQueue = std::make_shared<PersistentTaskQueue>(createLocalFilePath(taskDbFileName));
}
catch (const std::exception& ex) {
//This looks like: Error while constructing PackageManager: Package encryption keys do not match, trying to remove
Log::Errorf("PackageManager: Error while constructing PackageManager::PersistentTaskQueue: %s, trying to remove...", ex.what());
_taskQueue.reset();
utf8_filesystem::unlink(taskDbFileName.c_str());
try {
_taskQueue = std::make_shared<PersistentTaskQueue>(createLocalFilePath(taskDbFileName));
}
catch (const std::exception& ex) {
**throw FileException("Failed to create/open package manager task queue database", taskDbFileName); //App gets here.**
}
}
Initialization of package manager:
public class AndroidMapPackageManager : PackageManagerListener, IPackageManger
{
private readonly CartoPackageManager _packageManager;
public AndroidMapPackageManager()
{
var folder = CreateFolder(OfflineMapStrings.MapsFolderName); // /data/user/0/com.app.cityguide/files/mapmap2/
_packageManager =
new CartoPackageManager(OfflineMapsStrings.PackageManagerSource, folder)
{
PackageManagerListener = this
};
}
}
I am starting it just after the constructor worked after subscription to the listener events by other class. And, frankly saying, I never stop it. Do I need it?
With FIllRam Repoductivity is 100%. I used debug mode with no background allowed and now I tryed Ram Filler and result is same.
License issues:
05-25 12:41:41.091 26101 26101 E carto-mobile-sdk: CartoPackageManager: RegisterLicense not called, using random key for package encryption!
05-25 12:41:41.094 26101 26101 E carto-mobile-sdk: PackageManager: Error while constructing PackageManager: Package encryption keys do not match, trying to remove
The problem was that I was registering license key in SplashActivity. But, after resuming splash activity is not shown and, obviously, Registering of the license key was not performed. I have moved it to the custom application class and it worked:
public class CustomApplication : Application
{
public override void OnCreate()
{
base.OnCreate();
MapView.RegisterLicense(CartoApiKey, this);
}
}
I'm writing an angular 2 service for my NativeScript app that retrieves all the user's contacts. My current implementation uses a synchronous getContentResolver method like the one used in nativescript-contacts. The cursor.getCount reports over 7k cursors and freezes the app for a total of ~3 seconds. No good.
I'm following this guide, using-loaders-in-android, and having no luck so far.
Here's what I have so far:
declare let android: any
declare let java: any
import * as application from "application"
import {Injectable} from "#angular/core"
#Injectable()
export class ContactsService
extends android.support.v4.app.LoaderManager
implements android.support.v4.app.LoaderManager.LoaderCallbacks {
private contactsLoader: any = new android.support.v4.app.LoaderManager.LoaderCallbacks(
class extends android.support.v4.app.LoaderManager.LoaderCallbacks {
onCreateLoader(id, args) {
let projection: Array<string> = [
android.provider.ContactsContract.RawContactsColumns.CONTACT_ID,
android.provider.ContactsContract.ContactsColumns.DISPLAY_NAME,
android.provider.ContactsContract.ContactsColumns.HAS_PHONE_NUMBER,
android.provider.ContactsContract.ContactsColumns.LOOKUP_KEY,
android.provider.ContactsContract.ContactsColumns.PHOTO_URI,
android.provider.ContactsContract.CommonDataKinds.Phone.NUMBER,
android.provider.ContactsContract.CommonDataKinds.Phone.NORMALIZED_NUMBER,
android.provider.ContactsContract.CommonDataKinds.Phone.TYPE,
android.provider.ContactsContract.DataColumns.MIMETYPE,
]
return new android.support.v4.content.CursorLoader(
application.android.foregroundActivity,
android.provider.ContactsContract.Data.CONTENT_URI,
'data2 IS 2',
null,
null
).loadInBackground()
}
onLoadFinished(param0: android.support.v4.content.Loader, param1: java.lang.Object): void {
global.tnsconsole.dump('onLoadFinished > param0', param0)
global.tnsconsole.dump('onLoadFinished > param1', param1)
}
onLoaderReset(param0: android.support.v4.content.Loader): void {
global.tnsconsole.dump('onLoaderReset > param0', param0)
}
}
)
getContactsAsync(): Promise<any> {
// since the initLoader method is part of android.support.v4.app.LoaderManager
this.initLoader(1, null, this)
// but i get this error :(
// EXCEPTION: Error: Cannot convert object to Landroid/support/v4/app/LoaderManager$LoaderCallbacks; at index 2
return Promise.resolve([])
}
}
Does anyone know how to properly implement LoaderManager.LoaderCallbacks so I can run the cursor in a background thread?
Thank you!