Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8343517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:05:22+00:00 2026-06-09T06:05:22+00:00

I am trying to use reflection instead of including a jar file. I want

  • 0

I am trying to use reflection instead of including a jar file. I want to do this to reduce my apk size when I am not using the jar code…but if I include the code, I must include the jar. That being said, I am trying to grasp reflection and not doing well.

I have this code to see the methods available (and it works):

//initialize method params
Class[] paramInitialize = new Class[2]; 
paramInitialize[0] = Activity.class;
paramInitialize[1] = String.class;

try {
    Logger.i(DEBUG_TAG, "try statement");
    Class <?> tremorVideoCls = Class.forName("com.tremorvideo.sdk.android.videoad.TremorVideo");
    Class <?> tremorSettingsCls = Class.forName("com.tremorvideo.sdk.android.videoad.Settings");
    Object object = tremorVideoCls.newInstance();
    String apkName = this.getPackageManager().getApplicationInfo(this.getPackageName(), 0).sourceDir;
    loader = new dalvik.system.PathClassLoader(apkName, ClassLoader.getSystemClassLoader());
    tremorVideoCls = loader.loadClass("com.tremorvideo.sdk.android.videoad.TremorVideo");
    Method m[] = tremorVideoCls.getMethods();
    Method declaredM[] = tremorVideoCls.getDeclaredMethods();
    for (int i = 0; i < m.length; i++) {
        Logger.i(DEBUG_TAG, "getMethods is " + m[i].toString());
    }
    Field []field = tremorSettingsCls.getFields();
    for (int i = 0; i < field.length; i++) {
        Logger.i(DEBUG_TAG, "getFields is " + field[i].toString());
    }
    Method tremorInitialize = tremorVideoCls.getMethod("initialize", paramInitialize);
    Logger.i(DEBUG_TAG, "tremorInitialize is " + tremorInitialize.toGenericString());
//  tremorInitialize.invoke(object, this, ACCUWX.TREMOR_ADSPACE_TEST);

    } catch (ClassNotFoundException e) {
    } catch (NoSuchMethodException x) {
 ...

BUT, I get a logcat error throwing an exception:

08-06 11:48:51.134: W/System.err(11688): java.lang.NoSuchMethodException: initialize [class android.app.Activity, class java.lang.String]

Here is the logcat printing out that method:

08-06 11:48:51.118: I/Flagship/MainActivity(11688): getMethods is public static void com.tremorvideo.sdk.android.videoad.TremorVideo.initialize(android.content.Context,java.lang.String)

I’m not sure what do try next…any help greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T06:05:23+00:00Added an answer on June 9, 2026 at 6:05 am

    If the method which you are trying to invoke is

    public static void com.tremorvideo.sdk.android.videoad.TremorVideo.initialize(android.content.Conte‌​xt,java.lang.String)
    

    and the error is

    08-06 11:48:51.134: W/System.err(11688): java.lang.NoSuchMethodException: initialize [class android.app.Activity, class java.lang.String]
    

    It clearly indicates that the method expects android.content.Conte‌​xt but what you are passing android.app.Activity

    In the call

    tremorInitialize.invoke(object, this, ACCUWX.TREMOR_ADSPACE_TEST);
    

    instead of passing this you should pass an instance of android.content.Conte‌​xt.

    Hope this helps!!!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use Reflection.Emit in C# to emit a using (x) { ...
This is the first time am trying to use reflection for unit testing and
I am trying to use the JQuery reflection function and I am running into
I'm trying use mod_rewrite to rewrite URLs from the following: http://www.site.com/one-two-file.php to http://www.site.com/one/two/file.php The
I am need paint my image. I'm trying use JQuery in here this link:
I am trying to use Reflection.Emit to generate a wrapper class in a dynamic
Hi I am trying to use C# reflection to call a method that is
I have a tree of projectile classes I am trying to use some reflection
I'm trying to use java's reflection API on scala. I have a KDTree class
I am trying to use reflection to list the public members and methods of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.