2015-09-28 12 views
7

私はアンドロイドアプリケーションのSDKを開発しました。私たちはSDKを更新しました。私はこれらの変更がアプリケーションに反映される方法を探していますプレイストアにアプリを更新することなく、必要な助けが必要です。どんな助けもありがとうございます。SDK OTAの更新をロールオーバー

答えて

4

さてあなたは、動的に..あなたがあなたのストレージをwant..on今まで...以下のコードを作業しているときに更新することができDexLoaderクラス...を使用して、あなたのSDカードからjarファイルを読み込むことができ

final String libPath = Environment.getExternalStorageDirectory() +  "/test.jar"; 
    final File tmpDir = getDir("dex", 0); 

    final DexClassLoader classloader = new DexClassLoader(libPath, tmpDir.getAbsolutePath(), null, this.getClass().getClassLoader()); 
    final Class<Object> classToLoad = (Class<Object>) classloader.loadClass("com.test.android.MainActivity"); 

    final Object myInstance = classToLoad.newInstance(); 
    final Method doSomething = classToLoad.getMethod("doSomething"); 



    doSomething.invoke(myInstance); 

とあなたのライブラリファイルのコードでは、この

public class MainActivity { 



public void doSomething() { 

Log.e(MainActivity .class.getName(), "MainActivity : doSomething() called."); 
}} 

のようにすることができますあなたはどのような援助が必要な場合

1

あなたの状況にはこのような方法はありません。しかし、次回の更新でそれを有効にするためにできることが1つあります。 AndroidはコンパイルされたコードをDexClassLoaderで動的に読み込むことができます。したがって、新しいDEXファイルをコンパイルしてから、SDKにダウンロードして使用させてください。

// Internal storage where the DexClassLoader writes the optimized dex file to 
    final File optimizedDexOutputPath = getDir("outdex", Context.MODE_PRIVATE); 
    DexClassLoader cl = new DexClassLoader(dexInternalStoragePath.getAbsolutePath(), 
             optimizedDexOutputPath.getAbsolutePath(), 
             null, 
             getClassLoader()); 
    Class libProviderClazz = null; 
    try { 
     // Load the library. 
     libProviderClazz = 
      cl.loadClass("com.example.dex.lib.LibraryProvider"); 
     // Cast the return object to the library interface so that the 
     // caller can directly invoke methods in the interface. 
     // Alternatively, the caller can invoke methods through reflection, 
     // which is more verbose. 
     LibraryInterface lib = (LibraryInterface) libProviderClazz.newInstance(); 
     lib.showAwesomeToast(this, "hello"); 
    } catch (Exception e) { ... } 
+0

私を伝えることができます嘆願それをもう少し説明してください。私は、このコードを実装する場所と方法、そしてその流れをどういう方向にするのかを意味します。これは空気を介して動作しますか?事前に感謝します。 – Scorpio

+0

@HarrySharma、https://www.google.com.ua/webhp?sourceid=chrome-instant&ion=1&espv=2&es_th=1&ie=UTF-8#q=android%20dexclassloader%20example&es_th=1 –

関連する問題