- Android framework jar files
- adding `framework.jar` in android studio
- What is framework.jar
- Adding it to Android Studio
- Adding it to app/libs
- Adding it to dependencies
- Adding app.iml modifying gradle script
- Force to refer framework.jar during Java compile
- Result
- trongvu / build.gradle
- [HowTo] Odex FRAMEWORK, all Android versions may apply.
- Breadcrumb
- BreatheHT
Android framework jar files
Сообщение отредактировал sasha9182 — 04.02.21, 23:20
Ну же,мне нужна ваша помощь.Я опустил руки и смирился с тем что наши телефоны плохо дружат с градиентами.Ещё service.jar нужно разбирать,и редактировать там classes.dex,чего я не умею.
Сообщение отредактировал Димар — 01.02.16, 10:36
Насчет services.jar и classes.dex посмотри как я делал
а насчет градиента сам ничего толкового не добился.
Сообщение отредактировал sk0t — 20.08.14, 17:56
sk0t,
спасибо,нашел уже,и мне кажется что там не все.хочу заменить цвет текста на кнопке,и он видимо хранится в фреймворке,в файле btn_default.xml.но он не хочет открываться,или я не правильно его вытащил.просто как из архива.
фреймворк не хочет распаковываться.
Сообщение отредактировал 12enie — 28.10.10, 22:35
Сообщение отредактировал sk0t — 29.10.10, 00:12
Извини что не по теме не много, я редактирую LauncherProPlus, всё бы ничего вот только пересобранный файл launcher.xml в папке /res/layout-port/ не даёт лаунчеру запустится вылетая в ФК, может у тебя есть решение проблемы? Был бы очень благодарен!
Сообщение отредактировал Димар — 15.01.16, 20:25
Простые вопросы:
apk подписан?
что менялось в файле?
пересобран означает — разобран с помощью apk-tool, отредактирован, и собран с помощью apk-tool?
ещё по умолчанию собранный файл находится в папка куда распаковывался apk/dist и называется out.apk
Сообщение отредактировал sk0t — 29.10.10, 16:50
java -jar apktool.jar d -s file.apk foldername
tools.zip ( 1.13 КБ )
в архиве три файла
apktool-d.cmd — переносишь на него apk-файл содержащий классы(classes.dex): разбирает его в папку с тем же именем (phone.apk -> phone)
apktool-d-s.cmd — переносишь на него apk-файл не содержащий классы: разбирает его в папку с тем же именем (framework-res.apk -> framework-res)
apktool-b.cmd — переносишь на него папку с отредактированными файлами: собирает её в apk с именем out.apk (framework-res -> framework-res/dist/out.apk)
соответственно apktool.jar должен быть в той же папке.
2 Rang3r
скинь исходный apk и тот который ФК вызывает
PS 2 12enie
открываешь файл framework-res\res\values\styles.xml
ищешь там примерно такое (btn_default)
а здесь уже задается сам цвет
Первые два знака — прозрачность, остальные шесть — цвет в RGB
#ff000000 — ff — непрозрачный, 000000 — черный
можно изменить в любом из файлов
Сообщение отредактировал sk0t — 29.10.10, 20:35
sk0t, скинул в ЛС. Ответить можно и здесь, может кому-нибудь ещё тоже пригодится ответ :happy:
Сообщение отредактировал Rang3r — 29.10.10, 20:59
Источник
adding `framework.jar` in android studio
This post is part of another post dealing with how to let Android Studio work with a custom android framework where modifications have been made in the AOSP tree.
What is framework.jar
I do not have the full grasp of this jar file. BTW, a jar file is a Java archive format which may contain whatever resources. In the case for framework.jar , it would be a huge set of classes.
After an AOSP full image build, a framework.jar file can be found in the /system/framework directory in the output files. However, in my case the framework.jar was an empty file that contained nothing. This can be checked with the jar tf [jar file] command like the example below:
I am not sure if other AOSP builds might create a framework.jar file that may actually contain something. If so, then I believe you do not have to read the rest of this section.
Clearly, the /system/framework.jar is not the framework.jar file that I am looking for. After many googling, one result pointed me to checkout the intermediary files that are saved in the /out directory. I found a jar file that looked promising and it was /out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes.jar .
listing the contents of this jar file proved that it indeed contained the class that had been custom modified.
One questions that may rise is why is it not named framework.jar but classes.jar ? According to the google result, the classes.jar file is the file which will be renamed/transformed to framework.jar . There may be some minor changes applied to the classes.jar but it is not critical in which the android studio will not be able to understand.
Adding it to Android Studio
An android studio project has been created with the following tree structure.
Adding it to app/libs
The classes.jar file has been copied to app/libs directory and renamed to framework.jar .
Adding it to dependencies
In Android Studio after opening the project, go to File — Project Structure . In the pop-up window, go to Dependencies tab.
Click the + icon on the right to add a new dependency. Click Jar Dependency . Navigate and select app/libs/framework.jar file.
In the newly added libs/framework.jar entry, change the Scope to provided .
Click OK to save the changes.
The procedure above will allow the project to recognize the custom framework.jar . Then the question is which one will the project reference? Will it reference our custom framework.jar or will it reference to the official default SDK? Unfortunately, the project will still refer to the default SDK. The next step will take care of this problem.
Adding app.iml modifying gradle script
The main problem we now face is telling the project to reference framework.jar first instead of the default SDK. The hierarchy of referencing is written in app.iml file located in /app directory. Take a look and one can recognize a group of orderEntry items at the bottom of this file. The order of these orderEntry s defines which one to refer first over the other. We can see that the framework.jar entry is placed below the Android SDK entry.
We need to make sure that the framework entry is placed above the Android SDK entry. A gradle script can be added to the module’s build.gradle to make sure of this. In the module’s build.gradle , please add the following snippet:
Based on observation, a gradle sync or typical build will call preBuild directive. This will execute the snipped above (probably at the last moment due to the doLast command). The code will read the app.iml , save the orderEntry that contains the Android SDK, removes it from the iml file, add a new orderEntry at the last which is identical to the temporarily saved Android SDK orderEntry to the iml file. Eventually, the Android SDK orderEntry will be placed at the very last, thereby guaranteeing the framework.jar to be referenced first than the Android SDK.
Force to refer framework.jar during Java compile
A few more lines need to be added to the build.gradle file. The following code(not the whole but the part after “please add the following”) will be read during gradle’s configuration phase. What it means is, for the projects including subprojects where this build.gradle resides, all the tasks that are type of JavaCompile will be executed with an additional compiler argument -Xbootclasspath/p:app/libs/framework.jar . The reason why this code is necessary is self explanatory.
Result
After gradle sync, the “cannot resolve method” error has vanished.
And although I do not have a screenshot, the build of .apk file is successful too.
Источник
trongvu / build.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
// Top-level build file where you can add configuration options common to all sub-projects/modules. |
buildscript < |
repositories < |
google() |
jcenter() |
> |
dependencies < |
classpath ‘ com.android.tools.build:gradle:3.2.1 ‘ |
// NOTE: Do not place your application dependencies here; they belong |
// in the individual module build.gradle files |
> |
> |
allprojects < |
repositories < |
google() |
jcenter() |
> |
gradle . projectsEvaluated < |
tasks . withType( JavaCompile ) < |
options . compilerArgs . add( ‘ -Xbootclasspath/p:mobile/framework.jar ‘ ) |
> |
> |
> |
task clean ( type : Delete ) < |
delete rootProject . buildDir |
> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
preBuild < |
doLast < |
def imlFile = file(project . name + » .iml » ) |
println ‘ Change ‘ + project . name + ‘ .iml order ‘ |
try < |
def parsedXml = ( new XmlParser ()) . parse(imlFile) |
def jdkNode = parsedXml . component[ 1 ] . orderEntry . find |
parsedXml . component[ 1 ] . remove(jdkNode) |
def sdkString = » Android API » + android . compileSdkVersion . substring( » android- » . length()) + » Platform « |
println ‘ what ‘ + sdkString |
new Node (parsedXml . component[ 1 ], ‘ orderEntry ‘ , [ ‘ type ‘ : ‘ jdk ‘ , ‘ jdkName ‘ : sdkString, ‘ jdkType ‘ : ‘ Android SDK ‘ ]) |
groovy.xml.XmlUtil . serialize(parsedXml, new FileOutputStream (imlFile)) |
> catch ( FileNotFoundException e) < |
// nop, iml not found |
println » no iml found « |
> |
> |
> |
.. . |
dependencies < |
compileOnly files( ‘ framework.jar ‘ ) |
> |
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Источник
[HowTo] Odex FRAMEWORK, all Android versions may apply.
Breadcrumb
BreatheHT
Senior Member
Here in this tutorial, I will show some facts about Deodex and Odex, then explain how to odex the framework of a ROM(which is pretty annoying, you’ll find out). Credits goes to myself
This method should work on all Android devices.
First of all, what is odex? Something you should know about classes.dex.
Odex stands for Optimized dex. I’m not gonna explain a lot because I’m not sure if I’m right. First of all, in typical apk files, when you open it with WinRAR or something like that, you can find a file called «classes.dex»(this type of apk is deodexed). This file is the key. It contains the core codes of the apk. However the other type of apk comes with an *.odex file and doesn’t have classes.dex inside the apk file. This is odexed apk. There are 2 types of ROMs here, odexed and deodexed. Odexed ROMs’ classes.dex are already out of the apk files, while deodexed ROMs’ classes.dex are still in the apks. When Android executes an apk, it has to extract the classes.dex out and execute it. So when you flash an deodexed ROM, the first boot takes a long long time since the Android system needs to extract all the classes.dex into dalvik-cache(it shows «Optimizing apks» on the screen for 4.0 ROMs, shows boot animation on screen for 2.3 or below ROMs). However for the odexed ROMs, because the classes.dex are already out there, the system just grabs them and use them, without wasting time and storage space extracting classes.dex out.
Why odex framework?
It can boost your device a little by odexing your framework. Your phone can run more efficiently. Although it’s a complicated process, but trust me, it’s worth it.
What is so special about odexing framework files? What’s the difference?
Odexing an app is very easy, and I believe everyone knows how to do it. But odexing framework is really annoying. Why? Because apps and more like stand-alone things, they are not a part of system. You delete it, nothing bad happens, your phone still boots, you just get endless FC if you delete the wrong one, or missing status bar, that’s all. But framework files you cannot mess around. They are parts of the system. They have to match the system’s codes precisely, without any error, even the order of files(keep this in mind, very important). So for every ROM, the framework initialize codes are different(same RUU or other ROM based ROMs count as its base ROM), and you must modify the odexing binary to make it odex for you properly, or you can sit and watch the beautiful bootloop.
What’s the relationship between odexing apps and odexing framework?
Simple, but important. If you odexed apps, you cannot touch the framework. Framework always goes in the first place. If you wanna odex both, you must odex framework first. Or. «The Tragedy of App and Framework».
So what do we have to keep in mind before we start?
Keep your mind clear, prepare a bag of ice in case you feel dizzy with the codes, and MAKE ENOUGH SPACE FOR FRAMEWORK ODEXING. I would prefer you remove a few useless apks in /system/app first to make more room in system partition. Failing odexing may brick your device forever! Nah just kidding it will only cause you to bootloop. No big deal. Also, it won’t odex your framework-res.apk and always will not, so don’t feel bad and do it again and again till your phone burn . Make sure your device is ROOTED and enable USB debug. You need Java Runtime Environment.
What tools do you need?
Notepad++ and a magical rar that contains all you need to success.
Let’s get started.
1. Use your file manager to find init.rc at the very root directory of your phone and copy it to SDCard for later code editing, or you simply adb pull it out and skip the coping step. (If you know how to compile boot.img it is even easier, just unpack boot in Android Kitchen, look for line «export BOOTClassPATH». I’m not gonna introduce that method since most people can’t. Silly me, didn’t I just intoduced that? XD)
2. Connect USB, set mode as disk drive so you can access your SDCard. Copy init.rc into your computer. Open it with notepad, and find where it says «export BOOTClassPATH», create a new file and copy line «export BOOTClassPATH» into the new file. For example:
3. Open dexopter in the rar you downloaded with Notepad++. Find the lines that show the similar contents to the things after «export BOOTClassPATH». It is Line 21 to Line 35 on my laptop. Edit them according to the things you just copied out of init.rc. For example, if the first file is «X.jar», then you will have to edit the line into «dexopt-wrapper/system/framework/X.jar /system/framework/X.odex». Then repeat until you finish with all the files that are listed in the long list you copied out of init.rc. File order DOES MATTER. Use the bag of ice I told you to prepare eariler to make you sober if you feel dizzy with the codes. The lines may be more or less after you edited them, doesn’t matter.
4. Copy «dexopter» and «dexopt-wrapper» into /system/bin and set the correct permissions. Make sure they have enough permission to change your system files. Restart your phone.
5. Go to CMD and lead it to where adb.exe is(included in the rar). Type these in order:
Then the codes will run crazy in your cmd window. The odex process has begun!
6. If the odex process completed without error, you are half way there! Well it doesn’t mean you have to stare at your screen during the process. It’s about time we figure it out! The phone will automatically reboot once it’s finished. If it doesn’t and you are sure all are done, reboot manually.
7. If you can’t boot properly, go back and check everything carefully. If you can, then open your file manager and copy the entire framework directory into your SDCard. You can still adb pull and skip the next coping step.
8. Mount SDCard. Go into framework directory on your computer. Open every file that has an odex file with it, delete the classes.dex inside. WinRAR is okay. The files may seem ridiculously small after you delete the classes.dex, but don’t worry since classes.dex are already pulled out and turned into odex files.
9. Copy the whole framework folder into the folder where adb is at. Use adb to push all the files back into /system/framework.
10. After all the files are pushed in, reboot your phone.
11. If it still boots into the system, congratulations! You’ve successfully odexed your framework! If it doesn’t, then go back and read everything carefully. The most common error occurs when you are editing the dexopter code. You will have to redo everything again.
Done! Everything is ready to go!
You can directly grab the files you’ve odexed and put it in your custom ROM(must be the same base), just don’t forget the odex files.
Okay, hmm, what to say now? Still, I would be glad if you donated me, but if you don’t it’s okay, just reply and hit thanks .
Oh almost forgot, the magical rar: http://d-h.st/tYi
Big thanks to Scott, see him in #3. He explained why some files aren’t odexed and provided a easier method(but they all get you dizzy )
Big thanks to JSLEnterprises, see him in #4. He provided a newer busybox for Scott’s method.
Источник