Hello, welcome toPeanut Shell B2B Foreign Trade Network_Professional B2B E-commerce Platform_Free B2B Information Publishing Network!
18951535724

Android studio newsapp source dismantling: importing from gradle to secondary high score guide

   2026-10-09 NetworkingName1520
Key Point:Introduction: a set of information applications based on the andrea development tool, which includes complete source code and course design reports, which have been guided and evaluated by mentors as 98 points and which have been calibrated locally to ensure stable operation. Compressed packages containing 96 files of approximately 4. 63mb size, covering 27 java core logical files, 43 xml layouts and configuration resources, as well as graphic ma

Introduction: a set of information applications based on the andrea development tool, which includes complete source code and course design reports, which have been guided and evaluated by mentors as 98 points and which have been calibrated locally to ensure stable operation. Compressed packages containing 96 files of approximately 4. 63mb size, covering 27 java core logical files, 43 xml layouts and configuration resources, as well as graphic material such as webp, png, installation packages that can be installed directly, PDF format reports and explanatory documents. The project is difficult and suitable for the reference project structure, interfaces and data interfaces of students who are completing the end-of-cycle majors, as well as for gradual replication exercises by beginners who need the project. There are 194 people learning to download, and resource packages are equipped with operational source codes, install packages and reports to facilitate cross-sources understanding of typical features such as newslist displays, detailed page jumps and local data analysis, as well as to organize defence points based on reports。

It's a “model room” for high-point end-of-cycle jobs, and the hard part is how to unload them

Opens a downloaded android news app source package, and you'll probably see a src directory, a bunch of gradle files and a dozens of pages of word reports. The real problem is not that the code can run, but that there is a black box between the project and you: you don't know which documents are focused on teacher scoring, or what is in the report that can withstand a plea. That's the one thing that's going to work out: unhook the source package and tell you what each directory is about; write the steps and parameters that run through the project in android studio; and say, "how do you change your own version, how do you write the report?" suits someone who's doing an andre's end homework, graduation design, or wants to get a full story, app project source code. The goal is not to get you back to the code, but to get you to any of these items, to reproduce, change and clarify it。

2. Dismantling the source package: what exactly is in the project source code, anzor news app

I've seen a lot of "news app project source code + report" compression packages, which, although organized in a slightly different way by each author, are very different. Don't rush the run button for android studio. It'll take 10 minutes to go over the directory, and it'll be easier to get all wrong in the back. Such projects are usually long:

Paths, effects. What do you need attention for

I'm sorry, i'm sorry

Java or kotlin source code, containing activity, adapter, network request category

See if there are sub-contracts (activity/adapter/utils/bean) which indicate that the author is engineering conscious

I'm sorry, i'm sorry

Layout xml, picture, string, theme style

Focus on which pages below playout can reverse the list of functions

App/src/main/androidmanifest. Xml

Declaration rights, activity, application

See if there is a declaration of internet privileges, and there is no declaration that internet privileges are the most common news app the pit

It's not a good idea

Reliance library, application id, sdk version

It's decided if you can run up there

Build. Gradle (root directory)

Plugin version and global configuration

Which android gradle plugin version was used is the key to synchronous success or failure

I'm sorry

Gradle version management

If the project-specific gradle version does not match the local jdk, the error will be a bad one

2. 2 news app is a “security card” for the end of the exercise: four modules and a data chain

The news type app is favoured by teachers because it covers all the basic functions of mobile development: list display, web request, photo loading, page jump, data analysis. You don't have to do backends, you just have to find an available news data interface, and the whole app is alive. It is common to use open platforms such as aggregate data, skyline data, or simply place a json file locally to simulate the interface back. Functionally, these four pieces are the correct bottom line: the first page of the news list (to be displayed in recyclerview), the list entry click to jump to the details page (mostly webview loads in the original language), the categorisation of tab (technology, entertainment, sports, etc., for different request parameters), and the drop-down or cache (to reflect your understanding of a different task)。

2. 3 "translator" black box in android studio: look first, build. Gradle, then do it

A lot of people flip in the first step because they don't know what's written in the bild. Gradle first. There is a blood and tears experience: do not double-click the project, but check the dependent and sdk versions first. You open the root directory of the bild. Gradle, find the com. Androids. Tools. Bueld:gradle, whose version determines whether your local android studio can synchronise. If the source package was two to three years ago, the agp version could be 4. 2. X, and you have the latest version of android studio, the probability would be “plugin too old / incompatible”. At this point, there is no panic, and it is common to keep the project structure, to change root to your local version of agp, and to go to app/build. Gradle and reset it down to your sdk installed version. It is the only correct order to run through and talk about optimization。

3. Run the project: import, sync, connect the complete process of the simulator

Closes the first import of the item, the worst fear is that the environment does not match. I usually compare these three to "door-to-door": jdk compiles bytes, android sdk provides android api, gradle is responsible for stringing them together, and any version that doesn't match will report an error causing new hands to lose their skin. Check the jdk version of your machine first, at the terminal:

Java-version

If it's 17 or 21, and the project you opened was two or three years ago, it's up to you. Most of the old projects are based on jdk 8 or 11, and the common expression of jdk 17 is agp 's direct strike, reported as unsuppleted file major version 61. This is not the time for you to switch to jdk, but rather to assign a separate jdk environment to this project in android studio: file > project project > sdk office, pointing jdk to your installed version. Android studio's own jbr (jetbrains runtme) is usually enough. And look at the configuration in app/build. Gradle, what i need your attention is the combination of the numbers of compilesdk and minsdk。

3. 2 from opening the item to seeing the newslist: one step at a time

When the environment is aligned, the item is opened by file > open, selecting the root directory (not the app folder) after the decompression, and waiting for the bottom-right progress bar to run sync. If gradle's shell download fails, you're stuck in the "building" state, so instead of doing it, you can use the command line to verify the sdk environment:

# switch to platform-tools directory of android sdk
cd $android home/platform-tools
# view connected devices or simulators
i don't know

When the equipment was available, the project was packed and installed on the equipment in two ways: a green triangle in android studio directly, run, and an order to pack with gradle. The order line is more suitable for your screenshot to prove, "this is my own way of running."

Cd project root directory
# hit the debug bag, skip the test and speed
i don't know.
# load the generated apk onto the connected device
i'm sorry, but i'm sorry, but i'm sorry

Assembledebug generates an unsigned debug package, -x test to make the build skip the unit test, saves dozens of seconds. If you are an old project, you may encounter aapt2-related reporting errors for the first time, most of which are related to the absence of the built-tools version, and go to the ssdk manager to tick the corresponding version of the bild-tools。

3. 3 environmental "gensics" such as android studio settings and mirror sources

The demand under this heading has been repeatedly searched in the hot words. Android studio itself supports the chinese interface, but it's the ide display language and has nothing to do with the project code. The specific path is settings > plugins, searching for chinese language pack, which is the chinese menu once installed. But i would like to remind you not to let down your guard because the interface is chinese, and you're not really in the interface language, but rely on downloads. For the first time, the old project has to pull a bunch of com. Androids. Tools. Build and a third-party library, and if you don't have maven mirrors, you'll hang out at downloading. It is common to put google() and mavencentral() in front of root. Gradle's repository, where one or two reliable mirror warehouse addresses are added when the domestic network environment is poor. This step is one of the most pro-preventive parts of the encyclopedia。

4. Failure to do so will never be your end-of-cycle operation: web request, list, details page, how to change 4. 1 network request level: petrofit + gson interface definition and timeout parameters

You might want to change the source the most when you get the source code. Many old projects use httpurlcoNneaction or early volley, the code is silent, changing the interface to cry. My suggestion is simple: whatever the original project uses, you find an apiservice or httputil or something, and see which domain name it requests. The mainstream news app source will encapsulate retrofit, and you just need to change the interface path and parameters to your own data. A standard retrofit interface definition:

This post is part of our special coverage global voices 2011.
@get("api/news/list")
callGet newslist
@query("category")
@query("page")int page
@query("pagesize")int pagesize
;
♪ i'm sorry ♪

This code means that api/news/list is requested in the get mode, which combines classification, page number, number of pages per page behind the url and returns the type of result that is newsrespoI don't know. If you want to connect to your backstage, you need to renote the path in your note and the @query parameter name. In the creation of retrofit, there is one parameter that you can retort over time:

Okhttpclit = new okhttpclitt. Builder()
. CoNnecttimeout (15, timeunit. Seconds)
. Readtimeout (20, timeunit. Seconds)
. Writetimeout (20, timeunit. Seconds)
. Build();

CoNnecttimeout is the longest waiting time for a tcp connection, readtimeout is the maximum interval for a package to read after arrival, and writetimeout corresponds to the sending request. The news interface returns to the slow pot, mostly with the back end collating multiple sources, 15 seconds of time-out connection is more than acceptable for the campus network environment, and the anr risk is exposed by the general assembly. If you change these parameters from 10 to 15 and 20, you can write more in the report: "weak web environments consider time-out strategies."。

4. 2 recyclerview news card list: four copies of adapter that must be right yes

List page is always the front page of news app. If the source code is with listview, then it's probably a teaching template, not a high-scoring template; if it's recyclerview, you find the treasure. But it's not enough to have recyclerview, and sooner or later you have to change the card style so you have to know how adapter wrote it. The following is one of the most streamlined high-grades:

You know, public class newsadapter extends recyclerviewOther organiser
i don't knowWhat are you doing? Private oI don't know. Public newsadapterListen, oOther organiser
this. Newslist=list;
this. Lister=lister;
♪ i'm sorry ♪
@noNull.
@override
i'm not sure if i'm going to be able to do this@noNoll viewgroup parent, int viewtype)
view view = layoutinfrater. FromNtext()
. Infolate (r. Layout. Item news card, parent, false);
i don't know, new newsviewholder.
♪ i'm sorry ♪
@override
i don't knowN bindviewholder (@no)New newsviewholder, not position)
newsbean = newslist. Get;
holder. Title. Settext (bean. Gettile());
holder. Source. Settext (bean. Getsource());
/ / load cover map with glide, placeholder is the placeholder in load
glide. WithNtext()
. Load (bean. Getimageurl())
. Placeholder (r. Drawable. Img placeholder)
. Into (holder. Cover);
/ / click events are returned to activity processing, adapter does not skip the page noodles. I'm sorry, holderNicklister. O;
♪ i'm sorry ♪
@override
public int getitemcount()
no, no, no.
♪ i'm sorry ♪
you can't tell me what you're talking about. Textview type, source;
imageview cover;
newsviewholder (@no)@nullview)
(a) super (itemview);
title = itemview. Findviewbyid (r. Id. Tv title);
= itemview. Findviewbyid (r. Id. Tv source);
cover = itemview. Findviewbyid (r. Id. Iv cover);
♪ i'm sorry ♪
♪ i'm sorry ♪
i don't know what to doOther organiser
void oNews bean bean.
♪ i'm sorry ♪
♪ i'm sorry ♪

There are four points to focus here: first, oNcreateviewholder is only responsible for creating view holders, do not bind data here, otherwise it'll roll to cardon; second, oIn the nbindviewholder, take data from data sources, but be careful to shift from position after notify, and use get bindingadapterposition() as much as possible, instead of simply saving old positions; third, clicks are called back in adapter, not a new intent in adapter, which is painful; fourth, if the amount of data exceeds a few hundred, calculate the list difference with diffutil and notifydatasetchanged, which is one of the points in the report that can write "fluxe optimization", although the teacher is not sure to ask for details, but you can say that the principle is more than the sub-point. Img placeholder is your position map under res/drawable, and if not, delete the placeholder line, and the project can run。

4. 3 detailed pages are reproduced in webview loading original: three parameter control experiences

The details page of news app has two genres: one is the self-degrading of the json text on the client side, with the textview layout; the other is the direct webview loading of article links. Most of the “high-end big jobs” source codes choose the latter because they are simple and more visual than real news app. But webview is an easy guy with one less parameter: black screen or white screen:

Webview. Getsettings(). Setjavas(b) criptenabled;
webview. Getsettings(). Setdomstorageenabled;
webview. Getsettings(). Setloadwithoverviewmode;
webview. Setwebviewclit;
webview. Loadurl;

SetjavasCriptenabled (true) is the premise for many news stations to render pages, but if you open a page that is just textual, it is recommended that it be turned off, reducing the risk of a few script leaks; setdomstorageenabled controls the local storage of web pages, and some websites are lost if they are shut down; setloadwith overviewmode allows the page to adapt to the width of the screen, which is the basis for viewing the computer page on the phone. There's also the logic of returning key control:

@override
i don't knowNbackpressed()
if (webview. Cangoback())
webview. Goback();
♪ orse ♪
i don't knowNbackpressed();
♪ i'm sorry ♪
♪ i'm sorry ♪

This code solves the problem of having a number of layers of links at the user point, and the return key should not simply exit app, but should go back to the previous page. You can write in the report about the role of these three parameters and the process of returning to the inn, and the teacher can judge whether you are back-sourced or actually debugged。

Pipe avoidance and screening: where someone turns over, you bypass 5. 1 in advance

There are many reasons, but more than 90 per cent are in the download-dependent phase. The old version of the project, gradle, has no local caches, and, combined with network instability, downloads are repeated backstage. The solution is to wait: cancel the sync, open the terminal into the project directory to execute. /gradlew assembledebug-info, and use the --info parameter to see which package is being downloaded. If you don't move or anything like gradle-6. X-all. Zip, you can download the corresponding version manually from the gradle/wrapper/disks in the user directory, or switch to the locally cached version with the android studio's gradle jdk settings. Another common reason is that firewalls stop the offline, where mirroring sources are more practical than closing firewalls。

5. 2 symptoms: compiled times

This is a pretty scary story, actually, because the jdk version doesn't match the agp version. Major version 61 corresponds to jdk 17, which means you're running an agp 4. X project with jdk 17, which supports only jdk 11. There are two paths to the solution: either upgrade the agp from the build. Gradle to more than 7. 4 (and the gradle version also has to go up), or assign the jdk 11 to the project separately. In general, i recommend that the latter make the configuration of the document less risky. If you use the intellij system ide, you can find jdk drop-down frames in the project process > sdk location > gradle settings, then sync with jdk 11 on this machine, and the error disappears。

5. 3 symptoms: app toss back on the simulator, logcat displays "cleartext http technical not identified"

It's probably because the news interface used http://, not https://, and android 9 (api 28) started to use default bans on explicit traffic. There are three types of solutions that are prioritized: first, replace the interface with an https domain name and cure, but you may not have an https interface; second, add android: uses cleartexttraffic = "true" to the androidmanifest. Xml label, and release all explicit traffic for one second, suitable for the end-of-stage test scenario; and third, configure the network security configuration file, which allows only specific domain names to be specified, which is a business-level approach but has status when reporting. My proposal for the end-of-cycle project was the second, and then i wrote to the report, "in view of the existing news api, mostly the http protocol, the explicit flow is released at the application level for debugging."。

5. 4 symptoms: listed data are available, but all pictures are blank

Pictures are most common in the pans of the loading library. If you use glide in the source code, see if you rely on the old version of 4. 9. 0, which is occasionally twitched on android 10+. The second common reason is that the photo address is itself http, which is blocked by the explicit traffic restrictions above, and that the picture is often returned with the use of the clearexttraffic= "true". The third reason is more negative: the image url contains a special transliteration character, and the glide load failed to resolve it. You can handle the urlencoder. Encode (url, "utf-8") before loading, bearing in mind that the whole url is not encoded, but only part of the parameter, otherwise the slash becomes %2f leading to 404。

5. 5 phenomena: no response from the dot button in the simulator, no desktop icon coming out

The app module of some source packages does not correctly set the launcher entrance, and the int-file of activity in androidmanifest. Xml corresponds to the default entry instead of the desktop entry. It is common practice to check whether the main activity configuration contains both main and launcher actions:

If this code is commented on or missing, the app can compile it, but there are no icons on it. You will not find an application after the adb is installed successfully. The frequency of this problem in the source package is not low because some authors debug the entry into a custom splashaactivity and forget to change it back before submitting it。

How reports are written is like “high scores”: from stacking to supporting design decisions

The word “+ report” in the title that you ignore is often more valuable than the source code itself. The teacher had limited time to turn over the code, but the report would certainly read it. Structurally, i'm using a four-part “needs analysis - design selection - functional achievement - test optimization”, the first two paragraphs write what you've been working on, why not choose listview over recyclerview, why not write your own web request instead of retrofit; the last two paragraphs do not have large code, but rather a relationship chart of the key categories (with a simple modular map drawn by draw. Io) and two or three operational sketches. At the end of each paragraph, the phrase “problems and solutions encountered at this stage” is added, and any two or three of the above-mentioned pit-scrap sections are placed at a level higher than the rhetoric “achieved the presentation of the news”。

In reply, the teacher usually asks three points: where did your data come from, how did the interface go, how did the cache go? You put these three words in the test chapter in advance: the interface comes from open news sources, and the key is in buildcoNfig and gradle injections to avoid the explicit death in code; toast hints and displays local final cache data when interfaces fail; caches use memory caches plus disk cache two-stage policies. Even if your code doesn't work out, teachers usually agree with it. Turning the source code into an application that you've actually adopted, and turning the three sentences into real codes, will make it all right. As for myself, the first time i took a similar item was planted on the gladle sync and webview blank page, and then used to reconfigure, read logcat, and move the last code, almost no longer "turn the car." i hope these steps and lessons of today will help you。

Andre press release system source code

 
ReportFavorite 0Tip 0Comment 0
>Related Comments
No comments yet, be the first to comment
>SimilarEncyclopedia
Featured Images
RecommendedEncyclopedia
Table of Contents4 sections