#370·AndFix

fixed apk , fixed method returned string not working fine

Author: miladev95Created Mar 6, 2020Updated Dec 16, 2021

`public class App extends Application {

private static final String TAG = "test";

private static final String APATCH_PATH = "/out.apatch";
/**
 * patch manager
 */
private PatchManager mPatchManager;

@Override
public void onCreate() {
    super.onCreate();
    // initialize
    mPatchManager = new PatchManager(this);
    mPatchManager.init("1.0");
    Log.d(TAG, "inited.");

    // load patch
    mPatchManager.loadPatch();
    Log.d(TAG, "apatch loaded.");

    // add patch at runtime
    try {
        // .apatch file path
        String patchFileString = Environment.getExternalStorageDirectory()
                .getAbsolutePath()+"/Download" + APATCH_PATH;
        mPatchManager.addPatch(patchFileString);
        Log.d(TAG, "apatch:" + patchFileString + " added.");
    } catch (Exception e) {
        Log.e(TAG, "", e);
        Toast.makeText(getApplicationContext(),"catch : "+e.getMessage(),Toast.LENGTH_LONG).show();
    }

}

} `

`class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)
    main_txt.text = sayGoodBye()
    Toast.makeText(this,sayGoodBye(),Toast.LENGTH_SHORT).show()
}

fun sayGoodBye():String{
    return "hello"
}

} `

after replacing sayGoodbye function return string with goodbye string and generate apatch file with below command : bash apkpatch.sh -f app2.apk -t app1.apk -o . -k test.jks -p 123 -a test -e 123 and copy apatch to sdcard/download dirctory the output is : Screenshot_1583495083