Tag Archives: avd

AVD FFmpeg avcodec_ A solution of open2 returning – 1 (operation not permitted)

I’m working on Android hard decoding recently. Various attempts have been made on the compatible implementation of soft decoding and hard decoding. Later, I suddenly found that it was unable to decode normally, and even failed to open codec appeared.

Use RET = avcodec_ Open2 (CTX, codec, nullptr) the return value is – 1, and the error message is “operation not permitted”. It’s a headache for me. For Android development, permissions, alas AVStream* st = pFormatCtx->streams[streamIdx]; codec_context_ = avcodec_alloc_context3(pCodec); if (!codec_context_) { AVLOGE("Failed to allocate the codec context."); return -1; } if (avcodec_parameters_to_context(codec_context_, st->codecpar) < 0) { AVLOGE("Failed to copy codec parameters to decoder context."); return -1; } if (enable_hw_decode_) { if (codec_context_->codec_id == AV_CODEC_ID_H264) { pCodec = avcodec_find_decoder_by_name("h264_mediacodec"); if (pCodec) { avcodec_free_context(&codec_context_); codec_context_ = avcodec_alloc_context3(pCodec); using_hw_decode_ = true; } } } int ret = 0; if ((ret = avcodec_open2(codec_context_, pCodec, nullptr)) < 0) { AVLOGE("Failed to open codec. ret = %d, %s", ret, PAVUtils::get_error_string(ret)); return -1; }

Because it was copied once at first, but later, if hard decoding was used, the coder was selected again. As a result, the newly applied avcodec context failed to copy the operation parameters from stream to context. When I was using_ hw_ decode_ = Add avcodec before true _ parameters_ to_ context(codec_ context_, st-> codecpar); and it will work normally
it's strange why the relevant parameters are not copied, instead of returning invalid_ Par returns no instead_ What about permit?

AVD prompt Error:Could not Parse error string solution

Error:Could not parse Error String solution
Solution to the cause of the problem

The problem
Today, when installing APK into AVD, I found the virtual machine prompts installation failed:
The APK failed to install.
Error: Could not parse error string
The reason for this error is also unclear. At first, I thought it was just the installation package, but it didn’t work after three or four installation packages. I checked the API version and SDK version and found no problem, and it was running normally on the real machine.

The reasons causing
To get the best speed out of AVD, AS often recommends using the same CPU architecture AS your PC when installing AVD, which defaults to x86 architecture, while APK USES ARM architecture, which creates incompatibility.
When installing in a terminal, use the following command:
adb install path_to_your_app/name_of_your_app.apk
You may see the following error:
adb: failed to install name_of_your_app.apk: Failure [INSTALL_FAILED_NO_MATCHING_ABIS: failed to extract native libraries
The solution
1. Apk can be installed by installing an ARM-based AVD in AS (but the virtual machine is very, very card).

2. If you are compiling the program, you can change the program to x86 in the option, which can also run in the virtual machine.

insmod: init_module ‘hello.ko’ failed (Exec format error)

With the metere kernel, an Android simulator has been run and another compiled kernel is being added dynamically.
I initially found a hello.c file from the Web and wrote the Makefile the way he did, but when I ran the command insmod, it reported an error:
insmod: init_module ‘hello.ko’ failed (Exec format error)
Period, check a lot of information is still not solved, and then to test it according to this blog, succeeded, the connection address: http://blog.csdn.net/yf210yf/article/details/9901375
Next I post his Makefie file. There is no problem with the hello.c file, but the problem is with the Makefile. Write the Makefile the way he writes it and you can dynamically insert your own compiled kernel. The following code is posted:
Obj – m: = hello – yf. O
hello – yf – objs: = hello. O

KID: = ~/android – kernel/goldfish
the PWD: = $(shell PWD)
the ARCH = arm
CROSS_COMPILE = arm eabi –
CC = $(CROSS_COMPILE) GCC
LD = $(CROSS_COMPILE) LD

all:
the make – C $(KID) ARCH = $(ARCH) CROSS_COMPILE = $(CROSS_COMPILE) M = ${PWD} modules

the clean:
rm-rf *. O. CMD *. Ko *. Mod. C. tmp_versions
however, I do not know why he writes this way right now, I am looking into it. I’ve been updating this blog since I figured it out, but this problem has been solved.
I think I understand why, but look at this code:
All:
mak-c $(KID) ARCH=$(CROSS_COMPILE) M=${PWD} modules

I think this piece of code is the key to solve this problem. First, with mak-c $(KID), the local path of the current source code is given into the compile environment. Then assign the ARCH and cross-compiled environment variables separately, so that the above problems will not occur. You should have no problem writing makefiles this way if you want to compile your own kernel.
——————————————————————————————————————————————————————————————————– ———————–
To update this, the ‘M=’ option is used to add ‘M=dir’ to the make modules command when the user needs to compile an external module based on a kernel. The program will automatically look for the module’s source code in the dir directory you specify, compile it, and generate the KO file. This allows the generated KO files to be dynamically inserted into the kernel.