Tag Archives: Mobile development

Android learning notes 03: some problems and solutions in the learning process

In the process of learning Android development encountered a lot of problems, fortunately, the final search through the Internet have been solved. Now some of the problems I encountered in the process of learning Android development and the solutions are sorted out as follows.
1.R.java cannot be updated in real time
Description of the problem: New variables in the res file are not displayed in real time in R.java.
Solution: Select “Project” from the menu bar and check the “Build Automatically” option.
2.LogCat window is not displayed
Problem description: The LogCat window is not displayed in the lower right corner of Eclipse.
Solution: Select “Windows” from the menu bar, then “Show View”, and finally “LogCat”.
“Android Library Projects Cannot Be Launched
“Android Library Projects Cannot Be Launched” error
Solution: Select “Project” in the menu bar, then “Properties”, select “Android” in the pop-up window, and uncheck the IS Library option.
4. “This text field does not specify an InputType or a hint” error after adding EditText control to XML
Problem description: Add EditText control to XML. Control information is as follows.
& lt; The EditText
android: id = “@ + id/EditText”
android: layout_width = “match_parent”
android: layout_height = “wrap_content” & gt; < /EditText>
Error “This text field does not specify an InputType or a hint” at compile time.
Control lacks android:hint and android:inputType information. The android:hint is used to set the default text prompt displayed when EditText is null. Android: InputType is used to set the text type of EditText, which is used to help the input method display the appropriate keyboard type.
Add android:hint and android:inputType information to the control. Add the control information as follows.
& lt; The EditText
android: id = “@ + id/EditText”
android: hint = “0”
android: inputType = “number”
android: layout_width = “match_parent
” Android: layout_height = “wrap_content” & gt; < /EditText>
5. Warning message “Hardcoded string” XXX “, should use @string resource
Problem description: Add Button control in XML, control information is as follows.
& lt; The Button
android: id = “@ + id/mButton_mc”
android: text = “MC”
android: layout_width = “match_parent
” android: layout_height = “wrap_content” & gt;
& lt; /Button>
At compile time, prompt “Hardcoded string” MC “, should use @string resource warning.
The String MC is used in Android :text. You should define the String in string.xml and then use the String resource by calling the String resource name in string.xml. The advantage of doing this is that it can be a complete change and is useful when supporting multiple languages.
Solution: res–> in the project directory; values–> The following is the information for adding the String MC to string.xml.
< resources>
& lt; string name=”mc”> mc< /string>
< /resources>
Then, in the XML that uses the Button control, you use the string by calling its resource name, as follows.
& lt; The Button
android: id = “@ + id/mButton_mc”
android: text = “@ string/MC”
android: layout_width = “match_parent
” android: layout_height = “wrap_content” & gt;
& lt; /Button>
6. Nested weights are bad for performance
Analysis: When using a nested layout, both parent and child layouts use android:layout_weight, but when it is not required, a warning appears as shown in the title.
Solution: Remove the android:layout_weight that is not required for the sublayout, depending on the situation.
7. The solution to an error message “Please ensure that ADB is correctly located at:XXXXX” when starting the emulator
Executed: When using the correct source code, the following error message “Please ensure that ADB is correctly located at ‘D:\AndroidSDK4.0\ Android-SDK-Windows \ Platform-tools \ Adb.exe ‘and can be executed.”
D:\AndroidSDK4.0\ Android-SDK-Windows-Platform-Tools = D:\AndroidSDK4.0\ Android-SDK-Windows-Platform-Tools = PATH
Waiting for HOME (‘ Android.process.acore ‘) to be launched… Waiting for HOME (‘ Android.process.acore ‘) to be launched… The solution to this problem
Phenomena: When the simulator starts, it cannot start after Waiting for a long time (more than 5 minutes). It keeps saying “Waiting for HOME (‘ Android.process.acore ‘) to be launched…”. Information.  
Solution: Delete the current emulator and create a new one.
9.Android emulator landscape screen and portrait screen toggle
After the emulator is started, select the emulator and press Ctrl +F11 to switch between landscape and portrait screen of the Android emulator.
10. The imported Android project @Override returns an error
Phenology: When importing the Android project source code downloaded from the Internet into Eclipse, @Override returns an error.
On the project that reported the error, right-click on Properties–>; Java Compiler–> Select 1.6 in Compiler Compliance Level to refresh the project, and the error will not be reported.
 

OpenGL result white screen solution

Recently, the graphics department is doing computer experiment, and it needs to use OpenGL experimental operation, but my computer is not good enough.
Cannot display the correct result, each time is a white screen, can not display the desired result.
1. Problem: OpenGL is white
2. Environment: Win7 system, 64-bit. The model is Acer E1-571G, and the graphics card is Intel + Nvidia 710M 2G, VC6.0 and VS2008.
3, solution: enter the NVIDIA control panel (my computer directly desktop anti-key has), as shown in the picture global Settings to select high performance, application. Perfect solution, (*^__^*) Hee hee…

 
4, thinking: this setting should be the meaning of shielding set only open alone show, it should consume more power. So I tinkered with this control panel,
Here is a program setting, select Custom Settings, results… Useless, alas, forget it, solve good, first like this.
Have same problem to be able to refer to.

Reproduced in: https://www.cnblogs.com/hahanonym/p/3404884.html

Visionox shows app development record

Vicino display APP plays pictures and videos in turn:
1. Develop the advertisement bar to load three pictures:



The three images will be displayed in turn in the form of banner ads.
When you click the image, you will exit the APP. When you press the image long, you will load the video.

[Android test] solution for error closed after the carriage return of the ADB shell

2019 Unicorn enterprise heavily recruited Python engineer standard & GT; > >

Phenomenon 1: In the process of Monkey test by connecting USB with mobile phone, start a CMD window to input again, and error Closed appears after ADB shell returns. In some cases, this can happen with some cell phones.
Phenomenon 2: Unable to install ***. Apk on device ‘019417a3’: Unable to open Sync Connection!
Personally, I think the reasons for both phenomena are the same.
The solution is as follows:

One: Restart your computer, then look up your phone on your computer and start Eclipse
Second: Mobile phone – Settings – applications – development – USB debugging on and off again
Third: restart the phone, usb debugging on and off again.
Fourth: Try “adb kill-server” and then “adb start-Server “under CMD.
Personally, the second and third methods are more practical

Reproduced in: https://my.oschina.net/u/199776/blog/330604

Android ADB command adb devices error: protocol fault (no status)

Background:Installation of apk times error:protocol fault<no status>or error:device not found phone driver problems

The problem appears as follows: ADB Devices – L or ADB Devices

Solution 1
Windows:
The task manager sees the ADB process, closes it, and restarts ADB Start-Server.
Linux (My machine is Ubuntu)
Execute the command
gnome-system-monitor
Open task Manager and close adb’s.
Solution 2:

1, after launching the emulator.
2, enter the cmd command, and enter the cd D:\Android\sdk\platform-tools directory (Note: the reality is subject to the situation, here must enter the adb storage directory).
D:\android\sdk\platform-tools>adb kill-server #Shut down the service.
D:\Android\sdk\platform-tools>adb start-server #Restart the service.
Note: Checking related information on the Internet, we found the cause of this problem: The emulator will be idle for a period of time, which will cause an exception.

Solution Three.
Try again with a different phone.

My problem is due to a failed phone driver installation, it could be a data cable issue, but strangely doesn't affect my Appium!

How to Fix com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed

2019 unicorn enterprise to recruit Python engineer standard > > >

record import Google android case error solution is as follows: the android. Builder. Internal. The aapt. V2. Aapt2Exception: android resource linking failed

is as follows:

Android resource linking failed
Output:  /Users/chmy/git/android/googlesamples/android-MessagingService/Application/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:221: error: resource android:attr/fontStyle not found.
/Users/chmy/git/android/googlesamples/android-MessagingService/Application/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:222: error: resource android:attr/font not found.
/Users/chmy/git/android/googlesamples/android-MessagingService/Application/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:223: error: resource android:attr/fontWeight not found.
/Users/chmy/git/android/googlesamples/android-MessagingService/Application/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:224: error: resource android:attr/fontVariationSettings not found.
/Users/chmy/git/android/googlesamples/android-MessagingService/Application/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:225: error: resource android:attr/ttcIndex not found.
error: failed linking references.

Command: /Users/chmy/.gradle/caches/transforms-1/files-1.1/aapt2-3.2.0-4818971-osx.jar/cc4633529fe8cee26cd686b6b28203cf/aapt2-3.2.0-4818971-osx/aapt2 link -I\
        /Users/chmy/Library/Android/sdk/platforms/android-24/android.jar\
        --manifest\
        /Users/chmy/git/android/googlesamples/android-MessagingService/Application/build/intermediates/merged_manifests/debug/processDebugManifest/merged/AndroidManifest.xml\
        -o\
        /Users/chmy/git/android/googlesamples/android-MessagingService/Application/build/intermediates/processed_res/debug/processDebugResources/out/resources-debug.ap_\
        -R\
        @/Users/chmy/git/android/googlesamples/android-MessagingService/Application/build/intermediates/incremental/processDebugResources/resources-list-for-resources-debug.ap_.txt\
        --auto-add-overlay\
        --java\
        /Users/chmy/git/android/googlesamples/android-MessagingService/Application/build/generated/not_namespaced_r_class_sources/debug/processDebugResources/r\
        --custom-package\
        com.example.android.messagingservice\
        -0\
        apk\
        --output-text-symbols\
        /Users/chmy/git/android/googlesamples/android-MessagingService/Application/build/intermediates/symbols/debug/R.txt\
        --no-version-vectors
Daemon:  AAPT2 aapt2-3.2.0-4818971-osx Daemon #0

there is a lot of talk on the web about adding a configuration to gradle.properties, but the addition is not solved.

solution: the compiled version is not configured correctly. Original version number:

android {
    //
    compileSdkVersion 24

    buildToolsVersion '28.0.3'

    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 24

    }
...

after modification:

android {
    // 
    compileSdkVersion 28

    buildToolsVersion '28.0.3'

    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 28

    }

compiles again, and the problem is resolved. This is the solution I came across, others are not met for the time being.

reproduced in: https://my.oschina.net/who7708/blog/2236811

Android 10 open file exception open failed: eacces (permission denied) android:requestLegacyExternalStorage= “true“

in Android development, we generally use the following code to get the storage path, and the results are generally /storage/emulated/0

in AndroidManifest. Application node in the XML file with the android: requestLegacyExternalStorage = “true” attribute, as follows: </ p>

<application
    android:requestLegacyExternalStorage="true"

may be easy for developers, but for those who are new to android, it doesn’t use

now most mobile phones are Android version 10.0, when reading and writing files to the memory card, the problem of: open failed: EACCES (Permission denied) will occur. After adding the above one sentence of code to baidu, it has not been solved. The possible reason is that there is no dynamic access Permission added in the code snippet

dynamic read and write permission code:

final int REQUEST_EXTERNAL_STORAGE = 1;
if (ContextCompat.checkSelfPermission(MainActivity.this,
                        Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
                    ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 101);
                } else {
                    //downloadFile();
                    /**
                     * Write the code you want to execute here
                     */
                }

Where is

used?

for example, we now have a button, we get its click event in the Activity, click we want to add a photo in: /storage/emulated/0/DCIM, we want to perform the operation in else can

example:

no dynamic permissions added:

 utils_get.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                getDataFromokHttpUtils();
            }
        });

add dynamic permissions:

utils_down.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                final int REQUEST_EXTERNAL_STORAGE = 1;
                String[] PERMISSIONS_STORAGE = {
                        Manifest.permission.READ_EXTERNAL_STORAGE,
                        Manifest.permission.WRITE_EXTERNAL_STORAGE };
                if (ContextCompat.checkSelfPermission(MainActivity.this,
                        Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
                    ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 101);
                } else {
                    downloadFile();
                }

            }
        });

</ div>