Hello everybody, I'm having a problem developing an application (a launcher) with android studio.
Log:
01-31 15:26:27.744 22983-22983/joe2k01.launcher E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.NullPointerException
at joe2k01.launcher.DrawerLongClickListener.onItemLongClick(DrawerLongClickListener.java:36)
at android.widget.AbsListView.performLongPress(AbsListView.java:2878)
at android.widget.AbsListView$CheckForLongPress.run(AbsListView.java:2828)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:153)
at android.app.ActivityThread.main(ActivityThread.java:5336)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132)
at dalvik.system.NativeStart.main(Native Method)
01-31 15:26:27.986 22983-22989/joe2k01.launcher D/jdwp: processIncoming
01-31 15:26:27.986 22983-22989/joe2k01.launcher D/jdwp: handlePacket : cmd=0x1, cmdSet=0xC7, len=0x14, id=0x40002CA3, flags=0x0, dataLen=0x9
01-31 15:26:27.986 22983-22989/joe2k01.launcher D/jdwp: sendBufferedRequest : len=0x34
Click to expand...
Click to collapse
Code :
package joe2k01.launcher;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.SlidingDrawer;
import android.widget.TextView;
public class DrawerLongClickListener implements AdapterView.OnItemLongClickListener
{
SlidingDrawer drawerForAdapteer;
RelativeLayout homeViewForAdapter;
Context mContext;
public DrawerLongClickListener(Context ctxt, SlidingDrawer slidingDrawer, RelativeLayout homeView)
{
mContext = ctxt;
drawerForAdapteer = slidingDrawer;
homeViewForAdapter = homeView;
}
@override
public boolean onItemLongClick(AdapterView arg0, View item, int arg2, long arg3)
{
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(item.getWidth(), item.getHeight());
lp.leftMargin = (int) item.getX();
lp.topMargin = (int) item.getY();
LayoutInflater li = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
LinearLayout ll = (LinearLayout) li.inflate(R.layout.drawer_layout, null);
((ImageView)ll.findViewById(R.id.icon_image)).setImageDrawable(((ImageView) item.findViewById(R.id.icon_image)).getDrawable());
((TextView)ll.findViewById(R.id.icon_text)).setText(((TextView) item.findViewById(R.id.icon_text)).getText());
homeViewForAdapter.addView(ll, lp);
drawerForAdapteer.animateClose();
return false;
}
}
Click to expand...
Click to collapse
I'm tryng the app on my phone that runs android 4.2.1.
Can anyone help me? :silly:
Anyone can help me?
NullPointerException indicates that one of objects that you're using has null value. You can set breakpoint at the line on which this exceptions happens and inspect values of your objects. To do that, you should run application in Debug mode (a button next to Run).
Ok man, I' ll try later
Thank you, I fixed it. :good: :highfive:
Correct. A object has not yet create but you already call some method of it, system return null pointer
I've already solved the problem
Related
I wrote a module for myself to get started with xposed development when my phone (LG G2) was on Jelly Bean. I upgraded my phone to Kit Kat and noticed my module was no longer working and was firing a NoSuchMethod exception:
Code:
java.lang.NoSuchMethodError: android.media.AudioService#adjustStreamVolume(int,int,int)#exact
at de.robv.android.xposed.XposedHelpers.findMethodExact(XposedHelpers.java:179)
at de.robv.android.xposed.XposedHelpers.findAndHookMethod(XposedHelpers.java:129)
at de.robv.android.xposed.XposedHelpers.findAndHookMethod(XposedHelpers.java:136)
at com.bkdev.android.xposed.mods.ringtonesync.VolumeSync.handleLoadPackage(VolumeSync.java:21)
at de.robv.android.xposed.IXposedHookLoadPackage$Wrapper.handleLoadPackage(IXposedHookLoadPackage.java:20)
at de.robv.android.xposed.callbacks.XC_LoadPackage.call(XC_LoadPackage.java:34)
at de.robv.android.xposed.callbacks.XCallback.callAll(XCallback.java:70)
at de.robv.android.xposed.XposedBridge$2.beforeHookedMethod(XposedBridge.java:228)
at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:611)
at com.android.server.ServerThread.initAndLoop(Native Method)
at com.android.server.SystemServer.main(SystemServer.java:1478)
at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative(Native Method)
at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:631)
at com.android.server.SystemServer.main(Native Method)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608)
at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132)
at dalvik.system.NativeStart.main(Native Method)
I checked the API and it doesn't appear that adjustStreamVolume was deprecated or changed in any way, so I'm kind of confused as to why this would be happening. Maybe it's just my ignorance of xposed development so far, but here's my code with all of meat stripped out. From what I gather, the findAndHookMethod is the problem anyway. Any assistance as to why this is no longer working would be greatly appreciated. Let me know if more details are needed.
Code:
public void handleLoadPackage(final LoadPackageParam lpparam) throws Throwable {
if (!lpparam.packageName.equals("android"))
return;
// XposedBridge.log("In com.android.media");
findAndHookMethod("android.media.AudioService", lpparam.classLoader, "adjustStreamVolume", int.class, int.class, int.class, new XC_MethodHook() {
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.log("********Hooked 'adjustStreamVolume'********");
}
});
}
Try use InitZygote for "android".
Checking the source:
Java:
/** [user=690402]@see[/user] AudioManager#adjustStreamVolume(int, int, int) */
public void adjustStreamVolume(int streamType, int direction, int flags,
String callingPackage) {
…
}
@GermainZ
When I look at the developer reference for adjustStreamVolume in the AudioManager class, I don't see the extra parameter (String callingPackage) that you reference. Am I looking in the wrong place for the method I want to hook?
http://developer.android.com/reference/android/media/AudioManager.html#adjustStreamVolume(int, int, int)
Sent from my LG-LS980 using Tapatalk
bkertz said:
@GermainZ
When I look at the developer reference for adjustStreamVolume in the AudioManager class, I don't see the extra parameter (String callingPackage) that you reference. Am I looking in the wrong place for the method I want to hook?
http://developer.android.com/reference/android/media/AudioManager.html#adjustStreamVolume(int, int, int)
Sent from my LG-LS980 using Tapatalk
Click to expand...
Click to collapse
You're hooking AudioService, the page you're linking is the documentation for AudioManager.
GermainZ said:
You're hooking AudioService, the page you're linking is the documentation for AudioManager.
Click to expand...
Click to collapse
Well I really feel dumb now. It helps to look in the right place. Strange that this worked before for me. Do you have any recommendations between using AudioManager vs. AudioService? It appears AudioService is not on the developer pages.
Sent from my LG-LS980 using Tapatalk
bkertz said:
Well I really feel dumb now. It helps to look in the right place. Strange that this worked before for me. Do you have any recommendations between using AudioManager vs. AudioService? It appears AudioService is not on the developer pages.
Sent from my LG-LS980 using Tapatalk
Click to expand...
Click to collapse
Hook methods that are available in the SDK when you can. Hooking internal methods may stop working on newer versions since they can change at any time (they're internal methods after all).
Thanks.
Sent from my LG-LS980 using Tapatalk
SplashAcvtivity.java File
Code:
package com[.]nijinsha.didyouknow;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.os.Handler;
/**
* Created by Digit on 3/17/2016.
*/
public class SplashActivity extends AppCompatActivity {
// Splash screen timer
private static int SPLASH_TIME_OUT = 3000;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
new Handler().postDelayed(new Runnable() {
/*
* Showing splash screen with a timer. This will be useful when you
* want to show case your app logo / company
*/
@Override
public void run() {
// This method will be executed once the timer is over
// Start your app main activity
Intent i = new Intent(SplashActivity.this, MainActivity.class);
startActivity(i);
// close this activity
finish();
}
}, SPLASH_TIME_OUT);
}
Manifest.xml
Code:
<?xml version="1.0" encoding="utf-8"?>
<manifest
package="com.nijinsha.didyouknow">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true">
<activity
android:name=".SplashActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Black.NoTitleBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:theme="@style/Theme.AppCompat.DayNight.NoActionBar"
android:name=".MainActivity"
android:configChanges="keyboardHidden|orientation|screenSize">
</activity>
</application>
</manifest>
LOG FILE
03-17 14:53:21.490 7053-7053/com.nijinsha.didyouknow E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.nijinsha.didyouknow, PID: 7053
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.nijinsha.didyouknow/com.nijinsha.didyouknow.SplashActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2327)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2378)
at android.app.ActivityThread.access$800(ActivityThread.java:155)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1244)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5433)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.support.v7.app.AppCompatDelegateImplV7.createSubDecor(AppCompatDelegateImplV7.java:340)
at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:309)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:273)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at com.nijinsha.didyouknow.SplashActivity.onCreate(SplashActivity.java:21)
at android.app.Activity.performCreate(Activity.java:5301)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2291)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2378)*
at android.app.ActivityThread.access$800(ActivityThread.java:155)*
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1244)*
at android.os.Handler.dispatchMessage(Handler.java:102)*
at android.os.Looper.loop(Looper.java:136)*
at android.app.ActivityThread.main(ActivityThread.java:5433)*
at java.lang.reflect.Method.invokeNative(Native Method)*
at java.lang.reflect.Method.invoke(Method.java:515)*
This line
Code:
at com.nijinsha.didyouknow.SplashActivity.onCreate(Sp lashActivity.java:21)
suggest that app crash in:
Code:
setContentView(R.layout.activity_splash);
Your activity extends AppCompatActivity, but in manifest You declared for this activity:
Code:
android:theme="@android:style/Theme.Black.NoTitleBar" >
You need to use another theme for this acitivty.
You must use AppCompat themes with activity that extended from AppCompatActivity class,
Code:
android:theme="@android:style/Theme.AppCompat.Light"
or don't extend your activity from AppCompatActivity.
Code:
public class SplashActivity extends Activity
So I'm trying to hook my specific application's class onCreate method, because that's when I initialize my DaggerComponent.
My application looks like this:
Code:
private ApplicationComponent component;
@Override
public void onCreate() {
super.onCreate();
component = DaggerApplicationComponent.builder()
.applicationModule(new ApplicationModule(this))
.build();
}
public ApplicationComponent getComponent() {
return component;
}
And in my Xposed loadPackage method, I'm trying to hook the component so I can inject it into the module like so:
Code:
String name = lpparam.packageName;
if (name.equals(Common.PACKAGE_NAME)) {
XposedHelpers.findAndHookMethod(Application.class, "attach", Context.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
findAndHookMethod(
XposedHelpers.findClass(Common.APPLICATION, lpparam.classLoader),
"onCreate",
new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
Application application = (Application) param.thisObject;
Class clazz = param.method.getDeclaringClass();
for (Field field: clazz.getDeclaredFields()) {
String typeName = field.getType().getName();
if (typeName.equals(ApplicationComponent.class.getName())) {
Object object = XposedHelpers.getObjectField(param.thisObject, field.getName());
Class<?> component = object.getClass();
Method injector = component.getDeclaredMethod(
ApplicationComponent.INJECTOR, Loader.class);
injector.invoke(Loader.this);
Logg.log("GOT PAST THE BULL");
}
}
}
});
}
});
}
However, this always leads to a ClassNotFoundException where my Loader (the xposed module) is not found on my apk.
Code:
03-29 15:13:05.186 8571-8571/software.umlgenerator I/Xposed: java.lang.NoClassDefFoundError: software/umlgenerator/xposed/loaders/Loader
at java.lang.Class.getDeclaredConstructorOrMethod(Native Method)
at java.lang.Class.getConstructorOrMethod(Class.java:468)
at java.lang.Class.getDeclaredMethod(Class.java:640)
at software.umlgenerator.xposed.loaders.Loader$1$1.afterHookedMethod(Loader.java:67)
at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:645)
at software.umlgenerator.UMLApplication.onCreate(Native Method)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1007)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4328)
at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative(Native Method)
at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:631)
at android.app.ActivityThread.handleBindApplication(Native Method)
at android.app.ActivityThread.access$1500(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "software.umlgenerator.xposed.loaders.Loader" on path: DexPathList[[zip file "/data/app/software.umlgenerator-1.apk"],nativeLibraryDirectories=[/data/app-lib/software.umlgenerator-1, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
at java.lang.Class.getDeclaredConstructorOrMethod(Native Method)*
at java.lang.Class.getConstructorOrMethod(Class.java:468)*
at java.lang.Class.getDeclaredMethod(Class.java:640)*
at software.umlgenerator.xposed.loaders.Loader$1$1.afterHookedMethod(Loader.java:67)*
at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:645)*
at software.umlgenerator.UMLApplication.onCreate(Native Method)*
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1007)*
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4328)*
at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative(Native Method)*
at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:631)*
at android.app.ActivityThread.handleBindApplication(Native Method)*
at android.app.ActivityThread.access$1500(ActivityThread.java:135)*
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)*
at android.os.Handler.dispatchMessage(Handler.java:102)*
at android.os.Looper.loop(Looper.java:136)*
at android.app.ActivityThread.main(ActivityThread.java:5001)*
at java.lang.reflect.Method.invokeNative(Native Method)*
at java.lang.reflect.Method.invoke(Method.java:515)*
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)*
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)*
at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132)*
at dalvik.system.NativeStart.main(Native Method)*
Any ideas?
So, I have written an app that emails a file on every boot iteration. I flashed a new ROM and now it isnt working. I reboot and run a logcat on boot and see that the logcat and or gmail is complaining about no e-mail application being installed.
The error seems to be:
Code:
05-06 11:53:52.813 2514 2624 I Gmail : getAccountsCursor
05-06 11:53:52.814 2514 2625 D ActivityThread: Loading provider com.google.android.gmail.provider;com.android.mail.notifier;com.google.android.gm.email.provider;com.google.android.gm.email.notifier: com.android.email.provider.EmailProvider
05-06 11:53:53.282 935 2233 W ActivityManager: Unable to start service Intent { cmp=me.bluemail.mail/com.android.emaileas.service.AttachmentService } U=0: not found
05-06 11:53:53.314 935 2081 W ActivityManager: Unable to start service Intent { cmp=me.bluemail.mail/com.android.emaileas.service.AttachmentService } U=0: not found
05-06 11:53:53.452 2514 2685 I Gmail : No Email application installed
05-06 11:53:53.452 2514 2685 I EmailMigration: No data to migrate
05-06 11:53:53.452 2514 2685 W EmailMigration: No Exchange migration, not the right Email provider version
I do in fact have gmail installed and i went as far as installing a 3rd party email client.
The code I have is an smtp client written by someone else that has been integrated with my code. Like i stated before, everything worked before the flash. I actually figured the issue out last time but cant remember the solution I implemented.
I came from DU 5.1 and moved to DU 6.0. I flashed 4 different ROMs in hopes that it was the ROM but this was not the case.
I am using a rooted Nexus 6 and developing on Linux with no IDE.
The SMTP Client:
GmailSender.java
Code:
package com.keysender;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.ByteArrayInputStream;
import android.util.Log;
import javax.mail.Message;
import javax.mail.Session;
import javax.mail.Transport;
import java.util.Properties;
import java.security.Security;
import javax.activation.DataSource;
import javax.activation.DataHandler;
import javax.mail.internet.MimeMessage;
import javax.mail.PasswordAuthentication;
import javax.mail.internet.InternetAddress;
public class GmailSender extends javax.mail.Authenticator {
private String mailhost = "smtp.gmail.com";
private String user;
private String password;
private Session session;
static {
Security.addProvider(new com.keysender.JSSEProvider());
}
public GmailSender(String user, String password) {
this.user = user;
this.password = password;
try {
Properties props = new Properties();
props.setProperty("mail.transport.protocol", "smtp");
props.setProperty("mail.host", mailhost);
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.port", "465");
props.put("mail.smtp.socketFactory.port", "465");
props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
props.put("mail.smtp.socketFactory.fallback", "false");
props.setProperty("mail.smtp.quitwait", "false");
session = Session.getDefaultInstance(props, this);
}
catch(Exception e) {
e.printStackTrace();
Log.d("ERROR ", e.getMessage(), e);
}
}
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(user, password);
}
public synchronized void sendMail(String subject, String body, String sender, String recipients) throws Exception {
try{
MimeMessage message = new MimeMessage(session);
DataHandler handler = new DataHandler(new ByteArrayDataSource(body.getBytes(), "text/plain"));
//DataHandler handler = new DataHandler(new ByteArrayDataSource(body.getBytes(), "message/rfc822"));
message.setSender(new InternetAddress(sender));
message.setSubject(subject);
message.setDataHandler(handler);
if (recipients.indexOf(',') > 0)
message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(recipients));
else
message.setRecipient(Message.RecipientType.TO, new InternetAddress(recipients));
Transport.send(message);
}catch(Exception e){
e.printStackTrace();
}
}
public class ByteArrayDataSource implements DataSource {
private byte[] data;
private String type;
public ByteArrayDataSource(byte[] data, String type) {
super();
this.data = data;
this.type = type;
}
public ByteArrayDataSource(byte[] data) {
super();
this.data = data;
}
public void setType(String type) {
this.type = type;
}
public String getContentType() {
if (type == null)
return "application/octet-stream";
else
return type;
}
public InputStream getInputStream() throws IOException {
return new ByteArrayInputStream(data);
}
public String getName() {
return "ByteArrayDataSource";
}
public OutputStream getOutputStream() throws IOException {
throw new IOException("Not Supported");
}
}
}
JSSEProvider.java
Code:
package com.keysender;
import java.security.AccessController;
import java.security.Provider;
public final class JSSEProvider extends Provider {
public JSSEProvider() {
super("HarmonyJSSE", 1.0, "Harmony JSSE Provider");
AccessController.doPrivileged(new java.security.PrivilegedAction<Void>() {
public Void run() {
put("SSLContext.TLS",
"org.apache.harmony.xnet.provider.jsse.SSLContextImpl");
put("Alg.Alias.SSLContext.TLSv1", "TLS");
put("KeyManagerFactory.X509",
"org.apache.harmony.xnet.provider.jsse.KeyManagerFactoryImpl");
put("TrustManagerFactory.X509",
"org.apache.harmony.xnet.provider.jsse.TrustManagerFactoryImpl");
return null;
}
});
}
}
Relevant code snippet from my email method inside of my BootService class
Code:
try {
GmailSender sender = new GmailSender("[email protected]", "password");
sender.sendMail("keysender", text.toString(), "[email protected]", "[email protected]");
deleteFile();
}
catch(Exception e) {
e.printStackTrace();
Log.e("Mail could not be sent.", e.getMessage(), e);
}
hi i am new to xposed framework and java as well. :laugh:
my objective:
1. hook a class method - DONE
2. modify its first param using beforehooked - DONE
3. log the output and call the same method again in afterhooked. NEED HELP
i am tried like this
PHP:
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.log("result " + param.setResult);
param.setResult(null);
XposedBridge.log("calling method ");
XposedHelpers.callMethod(param.thisObject, "BodyDataByStr",param.args[0],param.args[1],param.args[2],param.args[3]);
}
but this is throwing null pointer exception in logs.
PHP:
java.lang.NullPointerException
at de.robv.android.xposed.XposedHelpers.callMethod(XposedHelpers.java:947)
at just.trust.me.Main$1.afterHookedMethod(Main.java:70)
at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:645)
at com.nob.mypp.h.a.BodyDataByStr(Native Method)
at com.nob.myapp.h.a.getBody(Unknown Source)
at com.nob.myapp.h.a.<init>(Unknown Source)
at com.nob.myapp.k.bk.<init>(Unknown Source)
at com.nob.myapp.k.bk.a(Unknown Source)
at com.mob.mypp.n.b$1.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at java.lang.Thread.run(Thread.java:856)
please help me.
hotwap said:
hi i am new to xposed framework and java as well. :laugh:
my objective:
1. hook a class method - DONE
2. modify its first param using beforehooked - DONE
3. log the output and call the same method again in afterhooked. NEED HELP
i am tried like this
PHP:
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.log("result " + param.setResult);
param.setResult(null);
XposedBridge.log("calling method ");
XposedHelpers.callMethod(param.thisObject, "BodyDataByStr",param.args[0],param.args[1],param.args[2],param.args[3]);
}
but this is throwing null pointer exception in logs.
PHP:
java.lang.NullPointerException
at de.robv.android.xposed.XposedHelpers.callMethod(XposedHelpers.java:947)
at just.trust.me.Main$1.afterHookedMethod(Main.java:70)
at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:645)
at com.nob.mypp.h.a.BodyDataByStr(Native Method)
at com.nob.myapp.h.a.getBody(Unknown Source)
at com.nob.myapp.h.a.<init>(Unknown Source)
at com.nob.myapp.k.bk.<init>(Unknown Source)
at com.nob.myapp.k.bk.a(Unknown Source)
at com.mob.mypp.n.b$1.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at java.lang.Thread.run(Thread.java:856)
please help me.
Click to expand...
Click to collapse
Code:
XposedBridge.log("result " + param.[COLOR="Red"]setResult[/COLOR]);
It should be getResult() right?
Also, you can use XC_MethodReplacement() instead of XC_MethodHook(), something like this:
PHP:
XposedHelpers.findAndHookMethod(........ new XC_MethodReplacement() {
@Override
protected Object replaceHookedMethod(MethodHookParam param) throws Throwable {
if (mBlaBlaBla == true) {
mBlaBlaBla = false;
XposedBridge.log("log this");
} else {
mBlaBlaBla = true;
// invoke original method
XposedBridge.invokeOriginalMethod(param.method, param.thisObject, param.args);
}
return null;
}
});
serajr said:
Code:
XposedBridge.log("result " + param.[COLOR="Red"]setResult[/COLOR]);
It should be getResult() right?
yes you are right. in the source its already getResult(), i made mistake while creating the thread.
Click to expand...
Click to collapse
Also note, calling the same method using callMethod inside its hook will basically run your hook recursively until stack overflows.
If you need to call the original method you should use XposedBridge.invokeOriginalMethod()
This will bypass any hooks attached to this method.